function get_dir_info($path){
???$handle = opendir($path);//打开目录返回句柄
???while(($content = readdir($handle))!== false){
???????$new_dir = $path . DIRECTORY_SEPARATOR . $content;
???????if($content == ‘..‘ || $content == ‘.‘){
???????????continue;
???????}
???????if(is_dir($new_dir)){
???????????echo "<br>目录:".$new_dir . ‘<br>‘;
???????????get_dir_info($new_dir);
???????}else{
???????????echo "文件:".$path.‘:‘.$content .‘<br>‘;
???????}
???}
}
get_dir_info($dir);
遍历文件夹下的所有文件和文件夹-php
原文地址:https://www.cnblogs.com/caoql/p/8692178.html