针对杂乱内容,可以自定义函数,通过正则表达式的方式只提取中文或者只提取英文。
具体方法
function get_cn($name){//只提取中文 preg_match_all('/[\x{4e00}-\x{9fff}]+/u', $name, $content); $string = implode('',$content[0]); echo $string; } function get_en($name){//只提取英文 preg_match_all('/[a-zA-Z]+/', $name, $content); $string = implode('',$content[0]); echo $string; }
本文属原创,转载请注明原文:https://zhimatong.com/jiaocheng/895.html
为保证教程的实用性及扩大知识面覆盖,如果您有相似问题而未解决,可联系在线客服免费技术支持。