I have a method to check whether a key is in a nested associative array:
private function checkKeyIsInArray($dataItemName, $array) {
foreach ($array as $key=>$value) {
if ($key == $dataItemName) return true;
if (is_array($value)) {
checkKeyIsInArray($dataItemName, $value);
}
}
return false;
}
It always returns true, regardless of the keys I include or do not include. Here is my test array:
Array
(
[0] => Array ( [reset_time] => 2013-12-11 22:24:25 )
[1] => Array ( [email] => [email protected] )
)
Please, what am I doing wrong? If I search for "reset_time" the method returns true (as I expect); when I search for "reset_expired" the method also returns true (which is incorrect).