本篇文章给大家带来的内容是关于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中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号