function replaceEmoji($nickname,$replaceStr="*")
{
//$nickname = json_decode('{"nickname":"\ue131\u6f6e\u978b\uff5e\u9ad8\u6893\u94b0\ud83d\udc5f\ud83d\udc5f\ud83d\udc5f"}');
//var_dump($nickname);
$nicknameTmp = json_encode($nickname);
//var_dump($nicknameTmp);
//$nicknameTmp = preg_replace("#(\\\ue[0-9a-f]{3})#ie","addslashes('\\1')",$nicknameTmp);
$nicknameTmp = preg_replace("#(\\\ue[0-9a-f]{3})#i",$replaceStr,$nicknameTmp);
$nicknameNoEmoji = json_decode($nicknameTmp);
return $nicknameNoEmoji;
} |
参考了别人的代码,正则替换成*号或者其他符号,微信传过来的是Unicode,但数据库无法存储,目前只做了最简单的处理。