note 122743 deleted from function.array-search by crell
| From: | crell@php.net | Date: | Thu, 31 Mar 2022 20:05:08 +0000 |
| Subject: | note 122743 deleted from function.array-search by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217942@lists.php.net to get a copy of this message | ||
Note Submitter: grayaahammed at gmail dot com
----
this is for searching a value inside a multidimontionnal array, and then return the parent of the
parent array that holds the value.
function recursive_array_search($needle,$haystack) {
foreach($haystack as $key=>$value) {
$current_key=$key;
if($needle===$value OR (is_array($value) && recursive_array_search($needle,$value)))
{
return $haystack[$key];
}
}
return false;
}