标签:
一、使用dir()函数:
1 function dirTree($directory) { 2 if (empty($directory)) { 3 return; 4 } 5 $dir = dir($directory); 6 $arr = []; 7 $i = 1; 8 while ($file = $dir->read()) { 9 echo ‘-->‘; 10 if ((is_dir("$directory/$file")) && ($file != ‘.‘) && ($file != ‘..‘)) { 11 $i++; 12 echo PHP_EOL . "第{$i}级目录:" . "$directory/$file" . PHP_EOL;; 13 dirTree("$directory/$file"); 14 } else { 15 echo $file . PHP_EOL; 16 } 17 } 18 } 19 20 $directory = "C:\Users\Yun\Downloads\app-master\config"; 21 echo "第1级目录:" . "$directory" . PHP_EOL;
结果:
二、
标签:
原文地址:http://www.cnblogs.com/atblog/p/4744043.html