PHP and JavaScript are really handy, and PHP native also provides support for JSON format. The main include JSON encoding and decoding two functions:
Json_endoce:http://cn.php.net/json_encode
json_dedoce:http://cn.php.net/json_decodejson_encode-encodes the variables and returns the JSON form of the value values, for example:
$arr = Array (' A ' =>1, ' B ' =>2, ' C ' =>3, ' d ' =>4, ' e ' =>5);
echo Json_encode ($arr);
?>
The above code executes after output:
{"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
If the data source to encode is (typically an array), the value contains Chinese, and the output is Unicode encoding after json_encode processing.
$arr = Array (' a ' = = ' Mango station ');
echo Json_encode ($arr);
?>
The above code executes after output:
{"A": "\u8292\u679c\u5c0f\u7ad9"}
PHP Bottom has done Unicode processing, if it is not intuitive enough, you can use the UrlEncode and UrlDecode method to bypass the transcoding process of Unicode:
$arr = Array (' A ' =>urlencode (' Mango Station ');
Echo UrlDecode (Json_encode ($arr)); The above code executes after output:
{"A": "Mango Station"}
Source: mangguo.org
http://www.bkjia.com/PHPjc/363891.html www.bkjia.com true http://www.bkjia.com/PHPjc/363891.html techarticle PHP and JavaScript are really handy, and PHP native also provides support for JSON format. Mainly includes JSON encoding and decoding two functions: Json_endoce:http://cn.php.net/json_encode js ...