/**
* 读取文件
* @param $dirname
* @param $ext
* @return array
*/
public static function scan_dir($dirname, $ext = "json")
{
$result = array();
if (is_dir($dirname)) {
if ($fp = @opendir($dirname)) {
$files = array();
//读取
while (($file = readdir($fp)) !== false) {
if ($file != '.' && $file != '..' && $file != '.svn') {
if (is_file($dirname . $file)) {
$extName = new SplFileInfo($file);
if ($extName->getExtension() == $ext) {
$files[] = $file;
}
}
}
}
$result = $files;
closedir($fp);
}
}
return $result;
}
标签:files,文件,读取,fp,result,file,dirname,目录
From: https://www.cnblogs.com/zxingduo/p/17285565.html