编写一个实现文件夹的递归遍历的函数
function dir_recurse($dir)
{
$i = 1;
if($handle = opendir($dir)) {
while(false !== ($file = readdir($handle))) {
if($file != "."&& $file != ".." ) {
if(is_dir($dir."/".$file) == true) {
$fullpath = $dir."/".$file;
dir_recurse($fullpath);
echo "$fullpath\n";
$i++;
}else {
$fullpath = $dir."/".$file;
echo "$fullpath\n";
$i++;
}
}
}
closedir($handle);
}
}