本文实例总结了php遍历目录方法。分享给大家供大家参考。具体如下:
1. 方法1
复制代码
1
2
3
4
5
6
7
8
9
10
11
12<?php function myscandir($pathname){ foreach( glob($pathname) as $filename ){ if(is_dir($filename)){ myscandir($filename.'/*'); }else{ echo $filename.'<br/>'; } } } myscandir('D:/wamp/www/exe1/*'); ?>
2. 方法2
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15<?php function myscandir($path){ $mydir=dir($path); while($file=$mydir->read()){ $p=$path.'/'.$file; if(($file!=".") AND ($file!="..")){ echo $p.'<br>'; } if((is_dir($p)) AND ($file!=".") AND ($file!="..")){ myscandir($p); } } } myscandir(dirname(dirname(__FILE__))); ?>
希望本文所述对大家的php程序设计有所帮助。
最后
以上就是淡定小白菜最近收集整理的关于php遍历目录方法小结的全部内容,更多相关php遍历目录方法小结内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复