I'm trying to get the key of a subarray based on a value in that subarray. So, based on the example below, how can I return the key of the array containing 'apple'?
Array (
[0] => Array (
[fruit] => apple
[colour] => green
)
[1] => Array (
[fruit] => banana
[colour] => yellow
)
)
So logically, something like:
if ('apple' is in $subarray) {
echo $subarray_key;
}
Thanks in advance.