fork download
  1. <?php
  2.  
  3. function createArray($array, $depth) {
  4. $result = null;
  5. $item = null;
  6.  
  7.  
  8. if(isset($array["path_length"])) {
  9. if(intval($array["path_length"]) >= $depth) {
  10. array_push($result, $array);
  11. }
  12. } else {
  13. foreach($array as $value) {
  14. if(intval($item["path_length"]) === $depth) {
  15. array_push($result, $value);
  16. $item = $value;
  17. } else {
  18. $item["children"] = createArray($value, $item["path_length"]);
  19. }
  20. }
  21. }
  22. return $result;
  23. }
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
Standard output is empty