Skip to main content
2 of 2
added 133 characters in body
rynhe
  • 2.5k
  • 1
  • 22
  • 27

if your array like this

$array = array(
              array("name" => "Robert", "Age" => "22", "Place" => "TN"), 
              array("name" => "Henry", "Age" => "21", "Place" => "TVL")
         );

Use this

function in_multiarray($elem, $array,$field)
{
    $top = sizeof($array) - 1;
    $bottom = 0;
    while($bottom <= $top)
    {
        if($array[$bottom][$field] == $elem)
            return true;
        else 
            if(is_array($array[$bottom][$field]))
                if(in_multiarray($elem, ($array[$bottom][$field])))
                    return true;
                
        $bottom++;
    }        
    return false;
}

example : echo in_multiarray("22", $array,"Age");

rynhe
  • 2.5k
  • 1
  • 22
  • 27