要几乎完全复制粘贴来自其他线程的答案,您可以使用preg_match:
$foundNonEnglishCharacter = false;
foreach ($words as $word) {
if (preg_match('/[^\00-\255]/', $word)) {
$foundNonEnglishCharacter = true;
break;
}
}
var_dump($foundNonEnglishCharacter); //If true, there's a non-english character somewhere - if not, then there's no english characters.
Run Code Online (Sandbox Code Playgroud)
正则表达式尸检:
[^\00-\255]- 任何不在 ASCII值0到255范围内的字符(因此,如果匹配,则它包含此范围之外的字符)
你可以找到常规的0-255 ascii值,以及它们在asciitable.com上的含义
| 归档时间: |
|
| 查看次数: |
131 次 |
| 最近记录: |