How to remove WeChat emoticons in php

藏色散人
Release: 2023-03-10 14:38:01
Original
2106 people have browsed it

php去除微信表情的方法:首先创建一个PHP示例文件;然后通过“protected function emoji_filter($str) {...}”方法去掉微信表情即可。

How to remove WeChat emoticons in php

本文操作环境: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;
 
    }
Copy after login

注:传递的参数需要是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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template