This article mainly introduces the method of generating and obtaining JSON files in PHP, involving PHP's operation skills for json format data and files. Friends in need can refer to the following
The examples in this article describe the generation and acquisition of PHP JSON file method. Share it with everyone for your reference, the details are as follows:
First define an array, then traverse the data table, put the corresponding data into the array, and finally convert the array through json_encode()
## The function of the #json_encode() function is to convert numerical values into JSON data storage format.
putjson.php:Copy codeThe code is as follows:
[["1","\u811A\u672C \u4E4B\u5BB6","m.sbmmt.com"],["2","\u7F16\u7A0B\u5F00\u53D1","php.cn"]] Then, put the JSON file in The data is read into PHP variables. getjson.php:
'; print_r($data); echo '
'; echo '编号:'.$data[0][0].' 姓名:'.$data[0][1].' 网址:'.$data[0][2]; echo '
'; echo '编号:'.$data[1][0].' 姓名:'.$data[1][1].' 网址:'.$data[1][2]; ?>
##Related recommendations:
php generation belt How to implement logo QR code#
The above is the detailed content of How to generate and obtain JSON files with PHP. For more information, please follow other related articles on the PHP Chinese website!