1 //phprecursively find if the directory and sub-file names contain Chinese space brackets2 functionSearchdir ($path,&$data){3 if(Is_dir($path)){4 $DP=dir($path);5 while($file=$DP-Read ()) {6 if($file! = '. ' &&$file! = ' ... '){7Searchdir ($path.‘ /‘.$file,$data);8 }9 }Ten $DP-close (); One } A if(Is_file($path)){ - $reg _chinese= '/[^\x00-\x80]/'; Match Chinese - $reg _brackets= '/\ ([^\)]+? \)/x '; Match parentheses the $reg _space= "/\s/"; Match Spaces - if(Preg_match($reg _chinese,$path) ||Preg_match($reg _brackets,$path) ||Preg_match($reg _space,$path)){ - $data[]=$path; - } + } - } + A functionGetdir ($dir){ at $data=Array(); -Searchdir ($dir,$data); - return $data; - } - Echo' <pre> '; - Print_r(Getdir ("D:\project\\"));//Specify directory
PHP recursive lookup in the specified directory and sub-file name contains Chinese spaces and parentheses