php源码之遍历目录下的所有的文件:
<!--?php
//遍历目录下的所有的文件 -- 递归调用
// <a rel="nofollow" href="
target="_blank"-->http://www.manongjc.com/article/1495.html
function get_all_file1($path){
if($path != '.' && $path != '..' && is_dir($path)){
//判断是否是目录,并且不是. 和..
$files = [];
//存储文件信息
if($handle = opendir($path)){
//打开
while($file = readdir($handle)){
//读取
if($file != '.' && $file != '..'){
$file_name = ($path . directory_separator . $file);
if(is_dir($file_name)){
//判断是否是目录
$files[$file] = get_all_file1($file_name);
//递归
}else{
$files[] = $file_name;
}
}
}
}
}
closedir($handle);
//关闭句柄
return $files;
}
// <a rel="nofollow" href="http://www.manongjc.com/article/1481.html"
target="_blank">http://www.manongjc.com/article/1481.html</a>
var_dump(get_all_file1('f:\apache\www\temp\php_demo'));
?>
以上就是php源码之遍历目录下的所有的文件的内容。
