/**
* 整个目录树
*
* author shyZhen <huaixiu.zhen@gmail.com>
* https://www.litblc.com
*
* @param $dir
* @return array
*/
public static function myScanDir($dir)
{
$files = [];
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
while (($file = readdir($handle)) !== false) {
if ($file != '.' && $file != '..') {
if (is_dir($dir . '/' . $file)) {
// 递归
$files[$file] = self::myScanDir($dir . '/' . $file);
} else {
$files[] = $dir . '/' . $file;
}
}
}
closedir($handle);
return $files;
}
}
}
/**
* 没有空文件夹,所有文件列表
*
* author shyZhen <huaixiu.zhen@gmail.com>
* https://www.litblc.com
*
* @param $path
* @param $fileName
*/
public function getFiles($path, &$fileName)
{
if (is_dir($path)) {
if ($resource = opendir($path)) {
while ($rows = readdir($resource)){
if (is_dir($path . '/' . $rows) && $rows != '.' && $rows != '..') {
$this->getFiles($path.'/'.$rows, $fileName);
} elseif ($rows != '.' && $rows != '..') {
$fileName[] = $path .'/'. $rows;
}
}
}
}
}
赞赏支持
本文由 litblc 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Sep 14, 2020 at 02:28 am
ok