如下所示:
$value){
if(is_dir($dir . '/' . $value)){
$files[$value] = scan_dir($dir . '/' . $value,$filter);
unset($files[$key]);
continue;
}
$pathinfo = pathinfo($dir . '/' . $value);
$extension = array_key_exists('extension',$pathinfo) ? $pathinfo['extension'] : '';
if(!empty($filter) && !in_array($extension,$filter)){
unset($files[$key]);
}
}
}
unset($key,$value);
return $files;
}