版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/github_38854224/article/details/81739855
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;
}