Home > Article > Backend Development > How to remove emoji in php
How to remove emoji in php: First create a PHP sample file; then filter out emoji through the "function filterEmoji($str){...}" method.
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!