/**
* 循环获取文件
*/
function scan_dir($dir) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if($file=='..' || $file=='.') continue;
if(is_file($dir.'/'.$file)) {
$file_list[] = $dir.'/'.$file;
continue;
}
$file_list[$file] = $this->scan_dir($dir.'/'.$file);
foreach($file_list[$file] as $infile) {
$file_list[] = $infile;
}
unset($file_list[$file]);
}
closedir($handle);
return $file_list;
}
}
$file = scan_dir('/home/wenguang/TestData/g2');
php读取某目录下的所有文件
最新推荐文章于 2024-07-27 22:51:17 发布