note 80692 deleted from function.array-search by levim
| From: | levim@php.net | Date: | Mon, 24 Feb 2014 22:41:59 +0000 |
| Subject: | note 80692 deleted from function.array-search by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198652@lists.php.net to get a copy of this message | ||
Note Submitter: pmmout at gmail dot com
----
MultiArray find function.
After some time unsuccessful looking for algorithm to find a string in multidimensional array I
wrote one:
<?php
function multidimArrayLocate($array, $text){
foreach($array as $key => $arrayValue){
if (is_array($arrayValue)){
if ($key == $text) $arrayResult[$key] = $arrayValue;
$temp[$key] = multidimArrayLocate($arrayValue, $text);
if ($temp[$key]) $arrayResult[$key] = $temp[$key];
}
else{
if ($key == $text) $arrayResult[$key] = $arrayValue;
}
}
return $arrayResult;
}
?>