fork download
  1. <?php
  2. $tree = [ 1 => [11 => ["a", "b"], 12 => ["a", "b", "3"], 13 => ["1", 2 => [1,2,3,4=>[1,2,3,4]], "a"]],
  3. 2 => [21 => [[1, 2], ["a", "b"]], 22=> [1, "a"], 23 => ["a", 2, 3], 24 => [1, 2]],
  4. 3 => [31 => ["a", "e"], 32 => [[1,2,3],[4,5,6],[7,8,9]], 33 => [1, "a"] ]
  5.  
  6. ];
  7.  
  8. //print_r($tree);
  9.  
  10. function drawArraySneaky ($var) {
  11. if(is_array($var)) {
  12. echo "+++";
  13. foreach ($var as $name => $value) {
  14. echo "$name:\n";
  15. echo "---";
  16. drawArraySneaky ($value);
  17. echo "---";
  18. }
  19. } else {
  20. echo "";
  21. echo $var . "";
  22. }
  23.  
  24. }
  25.  
  26.  
  27. drawArraySneaky($tree);
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
+++1:
---+++11:
---+++0:
---a---1:
---b------12:
---+++0:
---a---1:
---b---2:
---3------13:
---+++0:
---1---2:
---+++0:
---1---1:
---2---2:
---3---4:
---+++0:
---1---1:
---2---2:
---3---3:
---4---------3:
---a---------2:
---+++21:
---+++0:
---+++0:
---1---1:
---2------1:
---+++0:
---a---1:
---b---------22:
---+++0:
---1---1:
---a------23:
---+++0:
---a---1:
---2---2:
---3------24:
---+++0:
---1---1:
---2---------3:
---+++31:
---+++0:
---a---1:
---e------32:
---+++0:
---+++0:
---1---1:
---2---2:
---3------1:
---+++0:
---4---1:
---5---2:
---6------2:
---+++0:
---7---1:
---8---2:
---9---------33:
---+++0:
---1---1:
---a---------