Example of json data parsing in php

Source: Internet
Author: User
Tags php json
This article mainly introduces the php json data parsing example, a very important application. if you need it, you can refer to this article to demonstrate the php json data parsing method in the form of an example, this is a more practical feature 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. = "]"; // Before resolution $ 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.