//php递归查找该目录下及子文件名称是否包含中文空格括号
function searchDir($path,&$data){
if(is_dir($path)){
$dp=dir($path);
while($file=$dp->read()){
if($file!='.'&& $file!='..'){
searchDir($path.'/'.$file,$data);
}
}
$dp->close();
}
if(is_file($path)){
$reg_chinese = '/[^\x00-\x80]/'; //匹配中文
$reg_brackets = '/\( [^\)]+? \)/x'; //匹配括号
$reg_space = "/\s/"; //匹配空格
if(preg_match($reg_chinese,$path) || preg_match($reg_brackets,$path) || preg_match($reg_space, $path)){
$data[]=$path;
}
}
} function getDir($dir){
$data=array();
searchDir($dir,$data);
return $data;
}
echo '<pre>';
print_r(getDir("D:\project\\"));//指定目录