输入banner图图片脚本导航/分类

php中emoji转码显示的实现代码

本篇文章给大家带来的内容是关于php中emoji转码显示的实现代码,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

preg_match_all('/\[\[EMOJI:(.*?)\]\]/',$data['content'],$arr_content);//过滤掉emoji表情
foreach($arr_content[0] as $k=>$v){
        $emoji = str2emoji($v);
        $data['content'] = str_replace($v,$emoji,$data['content']);
}
function emoji2str($str){
    $strEncode = '';
    $length = ($str,'utf-8');
    for ($i=0; $i < $length; $i++) {
        $_tmpStr = mb_substr($str,$i,1,'utf-8');
        if(strlen($_tmpStr) >= 4){
            $strEncode .= '[[EMOJI:'.rawurlencode($_tmpStr).']]';
        }else{
            $strEncode .= $_tmpStr;
        }
    }
    return $strEncode;
}

相关推荐:

php项目中使用emoji表情的解决方法

php 解析emoji表情 支持微信

以上就是php中emoji转码显示的实现代码的详细内容,更多请关注Gxl网其它相关文章!