$file_path = "D:/words.txt";
$handle = fopen($file_path.'r');
$pattern_letter ='/\b[a-zA-Z]+\b/'; // Match English words$pattern_Chinese = '/[\x{4e00}-\x{9fa5}]+/u'; // Match Chinese characterswhile(($str = fgets($handle)) = =true){
    preg_match_all($pattern_letter.$str.$res_letter);
    preg_match_all($pattern_Chinese.$str.$res_Chinese);
    foreach($res_letter as $k= >$it){
        foreach($it as $kk= >$itt) {echo $itt.' ';
        }
    }
    foreach($res_Chinese as $k= >$it){
        foreach($it as $kk= >$itt) {echo $itt.' ';
        }
    }
fclose($handle);
Copy the code