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

How to remove emoji in php

藏色散人
Release: 2023-03-08 10:50:02
Original
4007 people have browsed it

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;
 }
Copy after login

[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!

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