One way to solve the Chinese is to first convert the Chinese into another encoding format, then use Json_encode (), and then decode the JSON string with decoding. There is also a way to be resolved in the new version of PHP, shown in the code below.
The following is a code example
<?php
Header ("Content-type:text/html;charset=utf-8");
$arrayName = Array (' City ' = ' Guangdong ', ' goods ' = ' cookies ');
$arr = Json_encode ($arrayName);
echo $arr. " </br> ";
Var_dump (Json_decode ($arr));
echo "</br>";
Echo UrlDecode (Json_encode (Ch_json ($arrayName))). " </br> ";
/*
Requires PHP version above 5.4
Echo Json_encode ($arrayName, Json_unescaped_unicode);
*/
function Ch_json ($arr) {
if (Is_array ($arr)) {
foreach ($arr as $key = = $value) {
$arr [UrlEncode ($key)] = Ch_json ($value);
}
}else{
Return UrlEncode ($arr);
}
return $arr;
}
?>
PS: Here again for you to recommend a few more useful JSON online tools for everyone to refer to the use:
Online JSON code inspection, inspection, landscaping, formatting tools:
Http://tools.jb51.net/code/json
JSON Online formatting tool:
Http://tools.jb51.net/code/jsonformat
Online Xml/json Mutual Conversion tool:
Http://tools.jb51.net/code/xmljson
JSON code online formatting/landscaping/compression/editing/conversion tools:
Http://tools.jb51.net/code/jsoncodeformat
C Language Style/html/css/json code formatting beautification tool:
Http://tools.jb51.net/code/ccode_html_css_json
Json-encode () How to decode it?