1、列出文件夹下的所有文件
- function findAllFiles($dir,$type='curr'){
- $root = scandir($dir);
- $result =[];
- foreach($root as $value){
- if($value === '.' || $value === '..'){
- continue;
- }
- if(is_file("$dir/$value")){
- if($type=='curr'){
- $result[] = $value;
- }else{
- $curr_dir = str_replace($cdir,'',$dir);
- $result[] = "$value";
- }
- continue;
- }else{
- if($type!='curr'){
- foreach(findAllFiles("$dir/$value",$type) as $v){
- $result[] = "$value/$v";
- }
- }
- }
- }
- return $result;
- }
复制代码
|