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

phpexcel导出emoji符号报错怎么办

PHPz
Release: 2020-09-05 11:58:21
Original
4846 people have browsed it

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);
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template