I have found this function courtesy of the php.net site...
function multi_array_search($search_value, $the_array)
{
if (is_array($the_array))
{
foreach ($the_array as $key => $value)
{
$result = multi_array_search($search_value, $value);
if (is_array($result))
{
$return[] = $result;
array_unshift($return, $key);
}
elseif ($result == true)
{
$return[] = $key;
}
}
return $return;
}
else
{
if ($search_value == $the_array)
{
return true;
}
else return false;
}
}
Which almost works perfectly as far as I need... but I have come across a stumbling block...
an array like:
array (array(id=>1, loc=>316),array(id=>2,loc=>315))
Is $infoarr, and the search is also an array (1,315,316) (set as $inclause)
for ($z=0;$z<count($inclause);$z++)
{
$result = multi_array_search($inclause[$z],$infoarr);
if ($result)
{
for ($i=0;$i<count($result);$i++)
{
if (!is_array($result[$i]))
{
$showarr[]=$infoarr[$result[$i]]['id'];
}
}
}
}
What I am looking the function to do - is only search the initial array (the_array) for the loc portion - ignoring the ID part, yet passing both back when the multi_array_search has found a record that satisifies the search...
Specifing to only look in the foreach where $key='loc' doesn't work... and I am at a loss as to where to go....
Any pointers ??