note 79534 added to function.array-search
| From: | toni dot garcia dot gutsens at gmail dot com | Date: | Sun, 02 Dec 2007 13:32:12 +0000 |
| Subject: | note 79534 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132737@lists.php.net to get a copy of this message | ||
Sorry, in the previous Post, empty arrays are not unset. Add three comment code lines.
function array_search_recursive($needle, $haystack,&$tree=Array(),$index=""){
if (is_array($haystack)){
if (count($tree)==0) $tree=array_merge(Array(),$haystack);
foreach($haystack as $k=>$current){
if (is_array($current)){
array_search_recursive($needle,$current,$tree,$index."[$k]");
eval("\$a=\$tree{$index}[{$k}];"); // unset all elements =empty array
if (count($a)==0) // is empty
eval("unset(\$tree{$index}[$k]);"); // unset array
}
else{
if ($current!=$needle){
eval("unset(\$tree{$index}[{$k}]);");
}
}
}
}
return $tree;
}
----
Server IP: 130.206.1.5
Probable Submitter: 87.219.85.252
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/79534
Del: integrated -- https://master.php.net/note/delete/79534/integrated
Del: useless -- https://master.php.net/note/delete/79534/useless
Del: bad code -- https://master.php.net/note/delete/79534/bad+code
Del: spam -- https://master.php.net/note/delete/79534/spam
Del: non-english -- https://master.php.net/note/delete/79534/non-english
Del: in docs -- https://master.php.net/note/delete/79534/in+docs
Del: other reasons-- https://master.php.net/note/delete/79534
Reject -- https://master.php.net/note/reject/79534
Search -- https://master.php.net/manage/user-notes.php