note 90034 deleted from function.array-search by levim
| From: | levim@php.net | Date: | Mon, 24 Feb 2014 22:43:30 +0000 |
| Subject: | note 90034 deleted from function.array-search by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198693@lists.php.net to get a copy of this message | ||
Note Submitter: office at drsoft dot com
----
If you wish to search a multidimensional array by keys:
<?php
function extract_values_by_key ( $array, $needle_key, &$out = array () ) {
foreach ( (array) $array as $key => $value ) {
if ( ! is_array ( $value ) && $key == $needle_key ) {
array_push ( $out, $value );
}
else {
extract_values_by_key ( $value, $needle_key, &$out );
}
}
return $out;
}
?>