I was trying to use the in_array function to check whether a value existed in a array which looked like the following:
$ri[$index][name]
$ri[$index][filename]

However although the values where inserted ok in_array did not seem to find them. Eg using in array to look for val when

$ri[1][name]=val

returned false. I tried to use a one dimensional array to store the names in i.e. $ri[1]=val and that worked fine. Does this mean that in_array will only work with one dimenensional arrays or am I missing something??

Thnks!

    From the manual

    If you want to search a multiple array for a value - you can use this function - which looks up the value in any of the arrays dimensions (like in_array() does in the first dimension).
    Note that the speed is growing proportional with the size of the array - why in_array is best if you can determine where to look for the value.

    Copy & paste this into your code...

    function in_multi_array($needle, $haystack)
    {
    $in_multi_array = false;
    if(in_array($needle, $haystack))
    {
    $in_multi_array = true;
    }
    else
    { 
    for($i = 0; $i < sizeof($haystack); $i++)
    {
    if(is_array($haystack[$i]))
    {
    if(in_multi_array($needle, $haystack[$i]))
    {
    $in_multi_array = true;
    break;
    }
    }
    }
    }
    return $in_multi_array;
    }
      Write a Reply...