php遍历目录方法小结
Jun 13, 2016 am 09:12 AMphp遍历目录方法小结
这篇文章主要介绍了php遍历目录方法,实例总结了常用的两种实现技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例总结了php遍历目录方法。分享给大家供大家参考。具体如下:
1. 方法1
?
1 2 3 4 5 6 7 8 9 10 11 12 |
function myscandir($pathname){ foreach( glob($pathname) as $filename ){ if(is_dir($filename)){ myscandir($filename.'/*'); }else{ echo $filename.' } } } myscandir('D:/wamp/www/exe1/*'); ?> |
2. 方法2
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
function myscandir($path){ $mydir=dir($path); while($file=$mydir->read()){ $p=$path.'/'.$file; if(($file!=".") AND ($file!="..")){ echo $p.' } if((is_dir($p)) AND ($file!=".") AND ($file!="..")){ myscandir($p); } } } myscandir(dirname(dirname(__FILE__))); ?> |
希望本文所述对大家的php程序设计有所帮助。

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
