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中文网其它相关文章!
……