Is there any better (= quicker ) solution to get all keys of value in array than foreach loop with if?
$array = array(\'apple\', \'orange\', \'pear\', \'banana\'
Alternatively, you could also use array_keys in this case, and providing the second parameter needle:
$array = array('apple', 'orange', 'pear', 'banana', 'apple', 'pear', 'kiwi', 'kiwi', 'kiwi'); $searchObject = 'kiwi'; $keys = array_keys($array, $searchObject); print_r($keys);
Sample Output