fork(2) download
  1. <?php
  2.  
  3. $array = [
  4. 'd' => [
  5. 'f',
  6. 'e',
  7. ],
  8. 'a' => [
  9. 'c',
  10. 'j',
  11. ],
  12. ];
  13.  
  14. function recur_asort(&$array) {
  15. foreach ($array as &$value) {
  16. if (is_array($value)) recur_asort($value);
  17. }
  18. return asort($array);
  19. }
  20.  
  21. recur_asort($array);
  22.  
  23. var_dump($array);
Success #stdin #stdout 0.02s 24668KB
stdin
Standard input is empty
stdout
array(2) {
  ["d"]=>
  array(2) {
    [1]=>
    string(1) "e"
    [0]=>
    string(1) "f"
  }
  ["a"]=>
  array(2) {
    [0]=>
    string(1) "c"
    [1]=>
    string(1) "j"
  }
}