Home > php教程 > php手册 > php+jquery+json中文乱码快速简单的解决

php+jquery+json中文乱码快速简单的解决

WBOY
Release: 2016-06-13 09:56:04
Original
1375 people have browsed it

今天我们利用了正则表达式来判断preg_replace替换由jquery转义过来的如\\u5c71\\u4e1c,但有的时间还是会出现中文问题,下面来看看解决办法

 代码如下 复制代码
$code = json_encode($str);
$code = preg_replace("#\u([0-9a-f]+)#ie", "iconv('UCS-2', 'UTF-8', pack('H4', '\1'))", $code);
?>
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template