I have an array parsing function that looks for partial word matches in values. How do I make it recursive so it works for multidimensional arrays?
function array_find($needle, array $haystack)
{
foreach ($haystack as $key => $value) {
if (false !== stripos($needle, $value)) {
return $key;
}
}
return false;
}
Array I need to search through
array(
[0] =>
array(
['text'] =>'some text A'
['id'] =>'some int 1'
)
[1] =>
array(
['text'] =>'some text B'
['id'] =>'some int 2'
)
[2] =>
array(
['text'] =>'some text C'
['id'] =>'some int 3'
)
[3] =>
array(
['text'] =>'some text D'
['id'] =>'some int 4'
)
etc..