note 111254 added to function.array-search
| From: | Thallion | Date: | Wed, 30 Jan 2013 15:57:53 +0000 |
| Subject: | note 111254 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193448@lists.php.net to get a copy of this message | ||
And if you want to find the entire series of keys to get to a value, try this.
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;
}
----
Server IP: 69.147.83.199
Probable Submitter: 64.251.52.34
----
Manual Page -- http://php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/111254
Del: integrated -- https://master.php.net/note/delete/111254/integrated
Del: useless -- https://master.php.net/note/delete/111254/useless
Del: bad code -- https://master.php.net/note/delete/111254/bad+code
Del: spam -- https://master.php.net/note/delete/111254/spam
Del: non-english -- https://master.php.net/note/delete/111254/non-english
Del: in docs -- https://master.php.net/note/delete/111254/in+docs
Del: other reasons-- https://master.php.net/note/delete/111254
Reject -- https://master.php.net/note/reject/111254
Search -- https://master.php.net/manage/user-notes.php