//遍历
function my_scandir($dir) {
$files = array();
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
while (($file = readdir($handle)) !== false) {
if ($file != "." && $file != "..") {
if (is_dir($dir . "/" . $file)) {
$files[$file] = my_scandir($dir . "/" . $file);
} else {
$files[] = $dir . "/" . $file;
}
}
}
closedir($handle);
return $files;
}
}
}
//递归打印多维数组
function printarray($array) {
foreach ($array as $key => $value) {
if (is_array($value)) {
printarray($value);
} else {
echo $value . "<br/>";
}
}
}
php遍历指定路径下的所有文件和文件夹
最新推荐文章于 2021-04-01 13:20:15 发布