I am trying to find value in multidimensional array
using recursive in_array
function, but I always get not found
.
This is the structure of array $v
:
Array
(
[0] => Array
(
[EV000005] => Array
(
[0] => Array
(
[0] => Array
(
[0] => EN
[1] => Thread holding
)
[1] => Array
(
[0] => nl-NL
[1] => Schroefdraadhouder
)
)
)
)
This is function:
public function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))) {
return true;
}
}
return false;
}
And this is how I call function which echoes to me not found
instead of found
:
echo $this->in_array_r("EV000005", $v) ? 'found' : 'not found';
I also tried to use $strict = true
but same result.
Why is the search for EV000005
unsuccessful in this case?