note 79640 added to function.array-search
| From: | info at bitandbit dot com dot ar | Date: | Thu, 06 Dec 2007 10:20:29 +0000 |
| Subject: | note 79640 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132882@lists.php.net to get a copy of this message | ||
Hi! i modify a little the function made by Chris, i thought it might be better to return an array
width the keys only, for example array(2) { [0]=> int(36) [1]=> int(70) }. by the way chris
awesome function, THANKS!
Regards
<?php
/*Erratum from my previous post.
* Returns all the keys to all the needles found
*and put them in an array.
*/
function array_search_recursive($needle, $haystack, $a=0, $nodes_temp=array()){
global $nodes_found;
$a++;
foreach ($haystack as $key1=>$value1) {
$nodes_temp[$a] = $key1;
if (is_array($value1)){
array_search_recursive($needle, $value1, $a, $nodes_temp);
}
else if ($value1 === $needle){
$nodes_found[] = $nodes_temp[$a];
}
}
return $nodes_found;
}
?>
----
Server IP: 190.2.55.3
Probable Submitter: 190.17.70.205
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/79640
Del: integrated -- https://master.php.net/note/delete/79640/integrated
Del: useless -- https://master.php.net/note/delete/79640/useless
Del: bad code -- https://master.php.net/note/delete/79640/bad+code
Del: spam -- https://master.php.net/note/delete/79640/spam
Del: non-english -- https://master.php.net/note/delete/79640/non-english
Del: in docs -- https://master.php.net/note/delete/79640/in+docs
Del: other reasons-- https://master.php.net/note/delete/79640
Reject -- https://master.php.net/note/reject/79640
Search -- https://master.php.net/manage/user-notes.php