note 111254 deleted from function.array-search by levim

From: Date: Mon, 24 Feb 2014 22:46:59 +0000
Subject: note 111254 deleted from function.array-search by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198666@lists.php.net to get a copy of this message
Note Submitter: Thallion ---- And if you want to find the entire series of keys to get to a value, try this. <?php function recursive_array_search($needle,$haystack) { foreach($haystack as $key=>$value) { $current_key=$key; if (is_array($value)) $val = recursive_array_search($needle,$value); if($needle===$value OR ($val != false and $val != NULL)) { if($val==NULL) return array($current_key); return array_merge(array($current_key), $val); } } return false; } ?>

« previous php.notes (#198666) next »