码迷,mamicode.com
首页 > Web开发 > 详细

遍历文件夹下的所有文件和文件夹-php

时间:2018-04-02 13:39:04      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:director   while   遍历文件夹   pre   add   new   content   pat   class   

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

标签:director   while   遍历文件夹   pre   add   new   content   pat   class   

原文地址:https://www.cnblogs.com/caoql/p/8692178.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!