Home >php教程 >php手册 >php+jquery+json中文乱码

php+jquery+json中文乱码

WBOY
WBOYOriginal
2016-05-25 16:52:541842browse

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

利用iconv函数解决代码如下:

<?php  
	$code = json_encode($str);  
	$code = preg_replace("#u([0-9a-f]+)#ie", "iconv(&#39;UCS-2&#39;, &#39;UTF-8&#39;, pack(&#39;H4&#39;, &#39;1&#39;))", $code);  
?>

               
               

文章网址:

随意转载^^但请附上教程地址。

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