note 65714 added to function.array-walk
| From: | nihaopaul at nihaopaul dot com | Date: | Sat, 06 May 2006 10:59:15 +0000 |
| Subject: | note 65714 added to function.array-walk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-110689@lists.php.net to get a copy of this message | ||
no sure if this should go under array-walk but it does what i need, it searches a multidimensionial
array by using an array to walk it, it either returns a value or an array.
function walker($walk, $array) {
if (count($walk) >0) {
foreach($array as $key => $value) {
if ($key == $walk[0]) {
if (is_array($value)) {
unset($walk[0]);
return walker(array_values($walk), $value);
} else {
if (isset($value)) {
if (count($walk) == 1) {
return $value;
} else {
return 0;
}
} else {
return 0;
}
}
}
}
return 0;
} else {
return $array;
}
}
----
Server IP: 219.239.98.8
Probable Submitter: 218.82.170.194
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.array-walk.php
Edit -- http://master.php.net/note/edit/65714
Del: integrated -- http://master.php.net/note/delete/65714/integrated
Del: useless -- http://master.php.net/note/delete/65714/useless
Del: bad code -- http://master.php.net/note/delete/65714/bad+code
Del: spam -- http://master.php.net/note/delete/65714/spam
Del: non-english -- http://master.php.net/note/delete/65714/non-english
Del: in docs -- http://master.php.net/note/delete/65714/in+docs
Del: other reasons-- http://master.php.net/note/delete/65714
Reject -- http://master.php.net/note/reject/65714
Search -- http://master.php.net/manage/user-notes.php