1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| /** *author: yzx *time:2015年7月13日0:41:54 *@file_path *to show file_path Directory Structure **/
function getAllDir($file_path="") { $result = array(); if(is_dir($file_path)||is_file($file_path)) { if(is_dir($file_path)) { $file_stuff = scandir($file_path); //$result["dir_load"] = "yes"; foreach($file_stuff as $item) { if($item == "."||$item == "..") { continue; } else { $child_file = $file_path."/".$item; if(is_dir($child_file)){ $result[$file_path][] = $child_file; $result[$child_file] = getAllDir($child_file); } else { $result[$file_path][] = $child_file; } } } } else if(is_file($file_path)) { //$result["file_load"] = "yes"; } } else { $result["status"] = "fail"; $result["mes"] = "the path is null,please input a true path"; } return $result; }
|