Assuming I give you the following array:
$array = array (
array (
'key' => 'value'
),
array (
'key' => 'another value'
),
array (
'key' => 'yet another value'
),
array (
'key' => 'final value'
)
);
What I want from this array is the position of the array with the value supplied. So If I am searching $array for the value of "yet another value" the result should be: 2 because the matching array is at position 2.
I know to do the following:
foreach ($array as $a) {
foreach ($a as $k => $v) {
if ($v === "yet another value") {
return $array[$a]; // This is what I would do, but I want
// the int position of $a in the $array.
// So: $a == 2, give me 2.
}
}
}
Update:
the key is always the same