How to convert multiple json strings into arrays in php

Source: Internet
Author: User
Convert multiple json entries in php to an array {"SchemeName": "design scheme for ontology protection engineering of Hutian kiln site (Hulu Kiln and horseshoe kiln)", "SchemeType": "technical solution (delegated to a third party )", "DeclareYear": "2014", "SchemeStatus": "under review", "Province": "Jiangxi Province" },{ "SchemeN php multiple json strings converted to Arrays
{"SchemeName": "design scheme for ontology protection engineering of Hutian kiln site (Hulu Kiln and horseshoe kiln)", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear ": "2014", "SchemeStatus": "under review", "Province": "Jiangxi Province" },{ "SchemeName": "South Gate of Gongcheng, yuanzhongdu ruins, dump Protection Project at southwest corner ", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus": "under review", "Province": "Hebei Province "}, {"SchemeName": "yuanzhongdu site environmental rectification project", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus ": "under review", "Province": "Hebei Province" },{ "SchemeName": "Neiqiu Xing Kiln site protection greenhouses", "SchemeType": "technical solution (delegated to a third party )", "DeclareYear": "2014", "SchemeStatus": "reviewing", "Province": "Hebei Province "}



How to convert to an array
------ Solution --------------------
Brackets
Pay attention to UTF-8 encoding.
$ S = <TXT
[{"SchemeName": "design scheme for ontology protection engineering of Hutian kiln site (Hulu Kiln and horseshoe kiln)", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear ": "2014", "SchemeStatus": "under review", "Province": "Jiangxi Province" },{ "SchemeName": "South Gate of Gongcheng, yuanzhongdu ruins, dump Protection Project at southwest corner ", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus": "under review", "Province": "Hebei Province "}, {"SchemeName": "yuanzhongdu site environmental rectification project", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus ": "under review", "Province": "Hebei Province" },{ "SchemeName": "Neiqiu Xing Kiln site protection greenhouses", "SchemeType": "technical solution (delegated to a third party )", "DeclareYear": "2014", "SchemeStatus": "reviewing", "Province": "Hebei Province"}]
TXT;

Print_r (json_decode ($ s, 1 ));
Array
(
[0] => Array
(
[SchemeName] => solution for ontology protection engineering of the Hutian kiln site (Hulu Kiln and horseshoe kiln)
[SchemeType] => technical solution (delegated to a third party)
[DeclareYear] = & gt; 2014
[SchemeStatus] => reviewing
[Province] => Jiangxi
)

[1] => Array
(
[SchemeName] => Earth tamping protection project at South Gate and southwest corner of Gongcheng, yuanzhongdu ruins
[SchemeType] => technical solution (delegated to a third party)
[DeclareYear] = & gt; 2014
[SchemeStatus] => reviewing
[Province] => Hebei
)

[2] => Array
(
[SchemeName] => yuanzhongdu site environmental rectification project
[SchemeType] => technical solution (delegated to a third party)
[DeclareYear] = & gt; 2014
[SchemeStatus] => reviewing
[Province] => Hebei
)

[3] => Array
(
[SchemeName] => Neiqiu Xingyao Ruins Protection greenhouses
[SchemeType] => technical solution (delegated to a third party)
[DeclareYear] = & gt; 2014
[SchemeStatus] => reviewing
[Province] => Hebei
)

)

------ Solution --------------------
$ Str = <
 [{"SchemeName": "design scheme for ontology protection engineering of Hutian kiln site (Hulu Kiln and horseshoe kiln)", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear ": "2014", "SchemeStatus": "under review", "Province": "Jiangxi Province" },{ "SchemeName": "South Gate of Gongcheng, yuanzhongdu ruins, dump Protection Project at southwest corner ", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus": "under review", "Province": "Hebei Province "}, {"SchemeName": "yuanzhongdu site environmental rectification project", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus ": "under review", "Province": "Hebei Province" },{ "SchemeName": "Neiqiu Xing Kiln site protection greenhouses", "SchemeType": "technical solution (delegated to a third party )", "DeclareYear": "2014", "SchemeStatus": "reviewing", "Province": "Hebei Province"}]
Phps;
Var_dump (json_decode ($ str, true ));

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.