php去除微信表情的方法:首先创建一个PHP示例文件;然后通过“protected function emoji_filter($str) {...}”方法去掉微信表情即可。
本文操作环境:windows7系统、PHP7.1版,DELL G3电脑
php怎么去除微信表情?
PHP去掉微信昵称表情
传入的$str为获取到的微信昵称,返回值为去除表情后的昵称
protected function emoji_filter($str) { if($str){ $name = $str; $name = preg_replace('/\xEE[\x80-\xBF][\x80-\xBF]|\xEF[\x81-\x83][\x80-\xBF]/', '', $name); $name = preg_replace('/xE0[x80-x9F][x80-xBF]‘.‘|xED[xA0-xBF][x80-xBF]/S','?', $name); $return = json_decode(preg_replace("#(\\\ud[0-9a-f]{3})#ie","",json_encode($name))); }else{ $return = ''; } return $return; }
注:传递的参数需要是utf-8编码
推荐学习:《PHP视频教程》
The above is the detailed content of How to remove WeChat emoticons in php. For more information, please follow other related articles on the PHP Chinese website!