Home >Backend Development >PHP Problem >How to remove emoji in php

How to remove emoji in php

藏色散人
藏色散人Original
2021-02-28 15:28:284010browse

How to remove emoji in php: First create a PHP sample file; then filter out emoji through the "function filterEmoji($str){...}" method.

How to remove emoji in php

The operating environment of this tutorial: Windows 7 system, PHP version 7.1, Dell G3 computer.

php to remove emoji expression code

I have been looking for it for a long time, and I personally tested the available code

// 过滤掉emoji表情
function filterEmoji($str)
{
    $str = preg_replace_callback(
            '/./u',
            function (array $match) {
                return strlen($match[0]) >= 4 ? '' : $match[0];
            },
            $str);
     return $str;
 }

[Recommended learning: "PHP video tutorial 》】

The above is the detailed content of How to remove emoji in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:What is php parent?Next article:What is php parent?