- 字符串过滤所有非英语字符和特殊符号仅保留英语字符,数字和空格:
$string = "abcd23uo*&* (.字符串过";
preg_match_all("/[\w\s]/i", $string, $matches);
print_r(implode('', $matches[0]));
- 字符串过滤所有非中文字符:
$string = "abcd23uo*&* (.字符串过";
preg_match_all("/([\x{4e00}-\x{9fa5}])/u", $string, $matches);
print_r(implode('', $matches[0]));
如有其他需求,欢迎留言