遍历某路径下的所有文件

<?php

class path_list {

function dir_list($dir) {

if (is_dir ( $dir ) === false) {

exit ( '目录路径不存在!' );

}

$list = scandir ( $dir );

foreach ( $list as $key => $file ) {

if (($file != '.') && ($file != '..')) {

if (is_dir ( $dir . '/' . $file )) {

$row [$file] = $this->dir_list ( $dir . '/' . $file );

} else {

$row [$file] = $file;

}

}

}

return $row;

}

}


你可能感兴趣的:(遍历某路径下的所有文件)