I have some troubles finding the right key in an array:
when I have an array: $haystack
$haystack = array(0 => 'apple',
1 => 'apple',
2 => 'pear',
3 => 'apple',
4 => 'banana');
and is use the function array_search
$key = array_search('apple', $haystack);
the function wil set the $key value to '0' ( $key = 0 )
I need to find the key of the fourth item in the array (3) which is also apple... Does anyone know a function that searches the array from a given index and returns a value?
for example something like:
array_search_start($needle, $haystack, $startPosition);