Return to Snippet

Revision: 65600
at December 29, 2013 00:17 by Sadeveloper


Initial Code
$array = array( 
   
        0 =>  array(  
            "fruit"   => "orange",  
            "id"    =>  4  
        ),  
        1   =>  array(  
            "test" =>  "test1",  
            "id" => 152  
        ), 
        2   =>  array(  
            "test" =>  "test2",  
            "id" => 152  
        )
);



function search_in_array($value, $array) {
     if(in_array($value, $array)) {
          return true;
     }
     foreach($array as $item) {
          if(is_array($item) && search_in_array($value, $item))
               return true;
     }
   return false;
}

$so = (search_in_array('orange',$array)) ? 'nothing' : 'daa';
echo $so;

Initial URL
http://www.softafzar.net

Initial Description
Function to check existence of value in multidimensional array.

Initial Title
PHP - Search in array

Initial Tags
php, search

Initial Language
PHP