php递归遍历之遍历文件夹下的所有文件和子文件
下面我来给大家推荐一个网友写的php递归遍历之遍历文件夹下的所有文件和子文件实例代码,希望对各位朋友有所帮助。
写一个函数,能够遍历一个文件夹下的所有文件和子文件夹。
<?php $dirs = 'e:/pdf'; function FileShow($dirs) { $dir = opendir($dirs); while ($f = readdir($dir)) { if ($f != '.' && $f != '..') { $file = $dirs . '/' . $f; if (is_file($file)) { echo 'FileName:' . $file . '<br />'; //echo 'FileName:'.iconv('gb2312','utf-8',$file).'<br />'; } else { FileShow($file); } } } } FileShow($dirs); ?>
本文地址:http://www.phprm.com/base/52995.html
转载随意,但请附上文章地址:-)