时间:2021-07-01 10:21:17 帮助过:22人阅读
/**************************** * 获取目录下的所有文件 * [$dir] 文件夹路径 ****************************/ function deepScanDir($dir) { $fileArr = array (); $dirArr = array (); $dir = rtrim($dir, '//'); if (is_dir($dir)) { $dirHandle = opendir($dir); while (false !== ($fileName = readdir($dirHandle))) { $subFile = $dir . DIRECTORY_SEPARATOR . $fileName; if (is_file($subFile)) { $fileArr[] = $subFile; } elseif (is_dir($subFile) && str_replace('.', '', $fileName) != '') { $dirArr[] = $subFile; $arr = $this->deepScanDir($subFile); $dirArr = array_merge($dirArr, $arr['dir']); $fileArr = array_merge($fileArr, $arr['file']); } } closedir($dirHandle); } return array ( 'dir' => $dirArr, 'file' => $fileArr ); }