if ($depth === 0) { $parent = $tree; } foreach ($tree as $key => $value) { $res = call_user_func_array($has_child, array($key, $value, $parent, $depth, $tree)); $html = ""; // has children if ($res === true) { $children_arr = render_tree($value, $has_child, $draw_hasChild, $draw_noChild, $depth + 1, $tree); if (is_callable($draw_hasChild)) { $html = call_user_func_array($draw_hasChild, array($key, $value, $children_arr, $parent, $depth, $tree)); } else { $html = sprintf($draw_hasChild, $key, $value, implode($children_arr)); } } elseif ($res === false) { if (is_callable($draw_hasChild)) { $html = call_user_func_array($draw_noChild, array($key, $value, $parent, $depth, $tree)); } else { $html = sprintf($draw_hasChild, $key, $value); } } $html_stack .= $html; } return $html_stack; } //foreach( as $folder => $file) { echo "<ul>\n" . render_tree(Uploads::getFilesArray(), 'is_node', 'style_node', 'style_leaf') . "</ul>"; foreach (Uploads::getFilesArray() as $folder => $file) { // var_dump($file); } //}