note 58967 deleted from function.in-array by nlopess
| From: | nlopess@php.net | Date: | Wed, 28 Dec 2005 16:33:41 +0000 |
| Subject: | note 58967 deleted from function.in-array by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100867@lists.php.net to get a copy of this message | ||
Note Submitter: dmitry dot polushkin at gmail dot com
----
<?
/**
* Search for a key and returns it. Recursive.
*
* @param array $array where to search
* @param string $search search for a key
* @return (string || array) where key found
* @version 1.0
* @author Solid (http://dmitry.info)
*/
function search_key($array, $search) {
$return = '';
while($element = each($array)) {
if(is_array($array[$element['key']])) {
$return = search_key($array[$element['key']], $search);
}
if(strstr($element['key'], $search)) {
$return = $element['value'];
}
if(!empty($return)) {
break;
}
}
return $return;
}
?>