使用php过滤emoji表情

    /**
     * 过滤字符串中表情
     * @param $str string 昵称
     * @return string
     */
    public function filterEmoji($str) {
        $str = preg_replace_callback('/./u', function (array $match) {
            return strlen($match[0]) >= 4 ? '' : $match[0];
        }, $str);
        return $str;
    }
posted @ 2019-07-01 10:18  追梦。  阅读(838)  评论(0编辑  收藏  举报