您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP遍历目录下的全部文件

2026/1/8 15:17:27发布22次查看
代码如下:
function listdir($dir){ if(is_dir($dir)){ if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false){ if((is_dir($dir./.$file)) && $file!=. && $file!=..){ echo 文件名:,$file,
; listdir($dir./.$file./); }else{ if($file!=. && $file!=..){ echo $file.
; } } } closedir($dh); } }}
打印结果如下:
文件名:10
文件名: 5
2012-12-11.xls
2015-02-01.z
2015-03-11.txt
2015-04-01.rar
文件名: 8
可以根据需求改动代码。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product