PHP文件遍历小例子
时间:2021-07-01 10:21:17
帮助过:49人阅读
PHP文件遍历小例子
完整代码:
- $dir = "D:\workspace";
-
- function list_file($dir = '.'){
- $list = scandir($dir);
- echo '
'; - foreach($list as $file){
- $target = "$dir/$file";
- if ( is_dir($target) && $file != '.' && $file != '..' ){
- echo "
- $file
"; - list_file($target);
- } else if ( $file != '.' && $file != '..'){
- echo "
- $file
"; - }
- }
- echo '
'; - }
- list_file($dir);
|