PHP 遍历获取文件夹内所有文件路径
function xmsb_getPathList($path) { $result = []; $paths = scandir($path); foreach($paths as $item) { if($item != '.' && $item != '..') { $encode = mb_detect_encoding($item, ['ASCII', 'UTF-8', "GB2312", "GBK", 'BIG5']); $item = mb_convert_encoding($item, 'UTF-8', $encode); $fullpath = $path . '/' . $item; if(is_dir($fullpath)) { clearstatcache(); $result[$item] = xmsb_getPathList($fullpath); } else { $result[$item] = $fullpath; } } } return $result; }
欢迎转载,转载时请注明来源。