Search all values in multiple arrays
This function lets you search for a value in any level of an multiple array. One advantage is that it breaks the search when it finds the value.
<?php
function array_search_recursive($needle, $haystack){
$path=array();
foreach($haystack as $id => $val)
{
if($val === $needle) {
$path[]=$id;
break;
} else if(is_array($val)){
$found=array_search_recursive($needle, $val);
if(count($found)>0){
$path[$id]=$found;
break;
}
}
}
return $path;
}
?>