/**
* 遍历文件夹中的所有文件
* @param $dir_path 要读取的文件夹
* @param array $get_arr 保留循环数据
* @return array
*/
function list_file($dir_path,&$get_arr = []){
//域名地址
$header = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'.$_SERVER['HTTP_HOST'];
//得到所有的文件
$files_arr = scandir($dir_path);
foreach ($files_arr as $k=>$file){
$file = iconv("GB2312//IGNORE", "UTF-8", $file);
$item_path = $dir_path.'/'.$file;
if(is_dir($item_path)){//如果是文件夹则执行
if($file == '.' || $file == '..'){//判断是否为系统隐藏的文件.和..
continue;
}
$get_arr['dir'][] = $header.'/'.$item_path;
list_file($item_path,$get_arr);
}else{
$get_arr['file'][] = $header.'/'.$item_path;
}
}
return $get_arr;
}