2010-08-23 3 views

Répondre

7
function get_from_array($toBeSearchedArray , $searchValue , &$exactPath) 
{ 
     foreach($toBeSearchedArray as $key=>$value) 
     { 
        if(count($value) > 0 && is_array($value)) 
       { 
         $found = get_from_array($value , $searchValue , $exactPath); 
         if($found) 
         { 
          $exactPath = $key."=>".$exactPath; 
          return TRUE; 
         } 
       } 
       if($value == $searchValue) 
       { 
         $exactPath = $value; 
         return true; 
       } 
     } 
     return false; 
} 

$exactPath = ""; 
$argArray = array('a'=>'aaa', 'b'=> array ('bbb1', 'bbb2' => array('bbb3', 'bbb4'))); 
get_from_array($argArray , "bbb4" , $exactPath); 
echo $exactPath; 
+0

Oui, cela fonctionne. Merci –

Questions connexes