This is a PHP directory traversal code that is good in terms of code and speed. Friends in need can refer to it.
代码如下 | 复制代码 |
$path = '..'; function get_filetree($path){ $tree = array(); foreach(glob($path.'/*') as $single){ if(is_dir($single)){ $tree = array_merge($tree,get_filetree($single)); } else{ $tree[] = $single; } } return $tree; } print_r(get_filetree($path)); |