Home  >  Article  >  Backend Development  >  phpexcel导出emoji符号报错怎么办

phpexcel导出emoji符号报错怎么办

PHPz
PHPzOriginal
2016-06-06 20:16:564781browse

phpexcel导出emoji符号报错怎么办

phpexcel导出emoji符号报错怎么办?

phpexcel导出用户数据成excel时,如果昵称包含表情,会导致数据不完整。

过滤或替换emoji。因为emoji通过json_encode后,大部分都是u[ed] 开头的编码,所以先对昵称json_encode然后用正则过滤或替换成*,以下时相关代码:

$value = json_encode($value);
$value = preg_replace("/\\\u[ed][0-9a-f]{3}\\\u[ed][0-9a-f]{3}/","*",$value);//替换成*
$value = json_decode($value);

更多相关技术文章,请访问PHP中文网

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn