This article mainly introduces PHP's Json Chinese processing solution, which involves php coding and conversion related operation skills and has some reference value, for more information about PHP Json processing solutions, see the following section. We will share this with you for your reference. The details are as follows:
Json is a widely used format for passing strings. it is easier to understand AND operate than xml. in php, there are two functions, json_encode () AND json_deconde (). However, json does not support Chinese very well. if json_encode () is used to process such as arrays, and if the array contains Chinese characters, it will be blank.
One way to solve Chinese is to convert Chinese to another encoding format, then use json_encode (), and then decode the json string. There is another way to solve this problem in the new php version, which is shown in the following code.
Sample code:
'Guangdong ', 'goods' => 'Cookies'); $ arr = json_encode ($ arrayName); echo $ arr ."
"; Var_dump (json_decode ($ arr); echo"
"; Echo urldecode (json_encode (ch_json ($ arrayName )))."
";/* Require php versions 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 ;}?>
I hope this article will help you with PHP programming.
For more articles about PHP's Json processing solution, please refer to PHP's Chinese website!