This article mainly introduces the example of parsing json data in php. It is an important application. For more information, see
This article mainly introduces the example of parsing json data in php. It is an important application. For more information, see
This article demonstrates the php json data parsing method in the form of an example. This is a more practical function and will be shared with you for your reference. The Code is as follows:
<? Php $ data; $ data. = "["; for ($ I = 0; $ I <20; $ I ++) {$ data. = "{"; $ data. = "\" id \":\"". 110. "\", "; $ data. = "\" name \":\"". 110. "\", "; $ data. = "\" original_price \":\"". 110. "\", "; $ data. = "\" sale_price \":\"". 110. "\", "; $ data. = "\" introduce \":\"". 110. "\", "; $ data. = "\" content \":\"". 110. "\", "; $ data. = "\" nums \":". 110. ""; $ data. = "}"; if ($ I <19) {$ data. = "," ;}}$ data. = "]"; // prerequisite for parsing Yes $ data is in json format $ array = array (); $ de_json = json_decode ($ data, true); // var_dump ($ de_json ); $ count_json = count ($ de_json); for ($ I = 0; $ I <$ count_json; $ I ++) {$ array [$ I] ["id"] = $ de_json [$ I] ['id']; $ array [$ I] ["name"] = $ de_json [$ I] ['name']; $ array [$ I] ["original_price"] = $ de_json [$ I] ['original _ price']; $ array [$ I] ["sale_price"] = json_encode ($ de_json [$ I] ['sale _ price']);} var_dump ($ array);?>
If you are interested, you can debug the example in this article. I believe there will be new gains.