fork download
  1. <?php
  2. $array = array('key1' =>
  3. array('key11' =>
  4. array('key111' => 'value111',
  5. 'key112' => 'value112',
  6. 'key113' => 'value113',
  7. ),
  8. ),
  9. );
  10.  
  11. function getKeys($array, $prefix='', $separator = '/') {
  12. $return = array();
  13. foreach($array as $key => $value) {
  14. if (!is_array($value)) $return[] = $prefix . $key;
  15. else $return = array_merge($return, getKeys($value, $prefix . $key . $separator, $separator));
  16. }
  17. return $return;
  18. }
  19.  
  20. $keys = getKeys($array, '', '#');
  21.  
  22. print_r($keys);
  23. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => key1#key11#key111
    [1] => key1#key11#key112
    [2] => key1#key11#key113
)