Php json to array Array

Source: Internet
Author: User

I used to convert a PHP JSON file to an array file.Article. I think writing is not bad, but recently I found the conversion method of PHP built-in functions,

I am here to share with you my apologies to the comrades who have read the previous article and have taken you into the trap.

To convert a JSON object to a normal array, that is, the simplest method of array is to use the json_decode () method. You only need to write one more parameter at the end.

Json_decode ($ JSON, true );

In this way, JSON can be converted into an array, and the key remains in the original format.

$ JSON = '{"name": "zhangsan", "Age": 20, "sex": "Nan "}';

Print_r (json_decode ($ JSON, true ));

After JSON data is parsed, it will become the following Array

Array
(
[Name] => zhangsan
[Age] => 20
[Sex] => Nan
)

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.