Example of php reading local json files,
1. data. json File
{"Goods": [{"type": 1, "name": "wow selected", "product": [{"id": 98, "name ": "leather coat", "title": "exclusive single-bucket original liquor whisky Chinese New Year gift box Limited", "titleDesc": "Scotland maltose, Chinese customized version", "price": 1298.00 }, {"id": 99, "name": "brand underwear", "title": "exclusive 222 New Year gift box for single bucket original liquor whisky Limited", "titleDesc": "Scotland maltose, customized Chinese Version 222 "," price ": 1298.00}] },{" type ": 2," name ":" special offer "," product ": []}
2. php file
<? Php echo "GET parameters from the page"; $ type = $ _ GET ['type']; $ proId = $ _ GET ['id']; echo $ type. "product type"; echo $ proId. "Product Id"; // The variable $ json_string = file_get_contents ('json/data. json '); // use the true parameter to forcibly convert the JSON string to a PHP array $ data = json_decode ($ json_string, true); // display it to see // var_dump ($ json_string ); // var_dump ($ data); // print_r ($ data); // product cycle function foreachFun ($ d, $ type, $ proId) {foreach ($ d ["goods"] as $ key => $ Value) {if ($ value ["type"] = $ type) {$ results = $ value ;}} foreach ($ results ["product"] as $ key => $ value) {if ($ value ["id"] = $ proId) {$ result = $ value ;}} return $ result ;}$ res = foreachFun ($ data, $ type, $ proId); print_r ($ res);?>
The above example of php reading a local json file is all the content shared by the editor. I hope you can give us a reference and support the help house.