Home >Backend Development >PHP Tutorial > json里的编码后的中文如何还原

json里的编码后的中文如何还原

WBOY
WBOYOriginal
2016-06-13 13:40:171088browse

json里的编码后的中文怎么还原
像这个“\u6d59\u6c5f\u7701\u676d”怎么还原回中文

------解决方案--------------------
json_decode
------解决方案--------------------
linux
$str=preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $str);

windows
$str=preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2LE', 'UTF-8', pack('H4', '\\1'))", $str);

浙江省杭

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