note 105890 modified in function.array-keys by danbrown
| From: | danbrown@php.net | Date: | Fri, 23 Sep 2011 16:06:59 +0000 |
| Subject: | note 105890 modified in function.array-keys by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183385@lists.php.net to get a copy of this message | ||
Sorry for my english...
I wrote a function to get keys of arrays recursivelly...
<?php
function recursive_keys($input, $search_value = null){
$output = ($search_value !== null ? array_keys($input, $search_value) : array_keys($input)) ;
foreach($input as $sub){
if(is_array($sub)){
$output = ($search_value !== null ? array_merge($output, recursive_keys($sub, $search_value)) :
array_merge($output, recursive_keys($sub))) ;
}
}
return $output ;
}
?>
I hope it will be usefull
Regards
--was--
Sorry for my english...
I wrote a function to get keys of arrays recursivelly...
function recursive_keys($input, $search_value = null){
$output = ($search_value !== null ? array_keys($input, $search_value) : array_keys($input)) ;
foreach($input as $sub){
if(is_array($sub)){
$output = ($search_value !== null ? array_merge($output, recursive_keys($sub, $search_value)) :
array_merge($output, recursive_keys($sub))) ;
}
}
return $output ;
}
I hope it will be usefull
Regards
http://php.net/manual/en/function.array-keys.php