美文网首页
PHP存储微信昵称特殊符号过滤方法

PHP存储微信昵称特殊符号过滤方法

作者: 无穷369 | 来源:发表于2019-04-18 10:26 被阅读0次

    方法一

       protected function removeEmoji($clean_text) {
    
            // Match Emoticons
            $regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
            $clean_text = preg_replace($regexEmoticons, '', $clean_text);
    
            // Match Miscellaneous Symbols and Pictographs
            $regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
            $clean_text = preg_replace($regexSymbols, '', $clean_text);
    
            // Match Transport And Map Symbols
            $regexTransport = '/[\x{1F680}-\x{1F6FF}]/u';
            $clean_text = preg_replace($regexTransport, '', $clean_text);
    
            // Match Miscellaneous Symbols
            $regexMisc = '/[\x{2600}-\x{26FF}]/u';
            $clean_text = preg_replace($regexMisc, '', $clean_text);
    
            // Match Dingbats
            $regexDingbats = '/[\x{2700}-\x{27BF}]/u';
            $clean_text = preg_replace($regexDingbats, '', $clean_text);
    
            return $clean_text;
        }
    

    方法二

    preg_replace("/[\x{1F600}-\x{1F64F}\x{1F300}-\x{1F5FF}\x{1F680}-\x{1F6FF}\x{2600}-\x{26FF}\x{2700}-\x{27BF}]/u","","这里是昵称")
    

    相关文章

      网友评论

          本文标题:PHP存储微信昵称特殊符号过滤方法

          本文链接:https://www.haomeiwen.com/subject/drkzwqtx.html