Convert multiple json strings in php to an array

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": "reviewing", "Province": "Jiangxi Province" },{ "SchemeName ": "yuanzhongdu site south gate of Gongcheng and protection project of tamping soil at Southwest angtai", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus ": "under review", "Province": "Hebei Province" },{ "SchemeName": "yuanzhongdu site Environmental Improvement Project", "SchemeType": "technical solution (delegated to a third party )", "DeclareYear": "2014", "SchemeStatus": "reviewing", "Province": "Hebei Province" },{ "SchemeName": "Neiqiu Xing Kiln site protection greenhouses ", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus": "under review", "Province": "Hebei Province "}



How to convert to an array


Reply to discussion (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 ":" reviewing "," Province ":" Jiangxi Province "},{" SchemeName ": "yuanzhongdu site south gate of Gongcheng and protection project of tamping soil at Southwest angtai", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus ": "under review", "Province": "Hebei Province" },{ "SchemeName": "yuanzhongdu site Environmental Improvement Project", "SchemeType": "technical solution (delegated to a third party )", "DeclareYear": "2014", "SchemeStatus": "reviewing", "Province": "Hebei Province" },{ "SchemeName": "Neiqiu Xing Kiln site protection greenhouses ", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus": "under review", "Province ": "Hebei province"}] TXT; print_r (json_decode ($ s, 1 ));
Array ([0] => Array ([SchemeName] => design scheme for ontology protection engineering of Hutian kiln site (Hulu Kiln, Horseshoe kiln) [SchemeType] => technical solution (delegated to a third party) [DeclareYear] => 2014 [SchemeStatus] => reviewing [Province] => Jiangxi Province) [1] => Array ([SchemeName] => yuanzhongdu ruins south gate of Gongcheng, south-west corner of the station Earth Protection Project [SchemeType] => technical solution (delegated to a third party) [DeclareYear] => 2014 [SchemeStatus] => reviewing [Province] => Hebei Province) [2] => Array ([SchemeName] => yuanzhongdu Site Environmental Remediation Project [SchemeType] => technical solution (delegated to a third party) [DeclareYear] => 2014 [SchemeStatus] => reviewing [Province] => Hebei Province) [3] => Array ([SchemeName] => [SchemeType] => technical solution (delegated to a third party) [DeclareYear] => 2014 [SchemeStatus] => reviewing [Province] => Hebei ))

$ Str = <
  
  

After adding [] to both sides, you can use json_decode to convert it to an array.

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 ":" reviewing "," Province ":" Jiangxi Province "},{" SchemeName ": "yuanzhongdu site south gate of Gongcheng and protection project of tamping soil at Southwest angtai", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus ": "under review", "Province": "Hebei Province" },{ "SchemeName": "yuanzhongdu site Environmental Improvement Project", "SchemeType": "technical solution (delegated to a third party )", "DeclareYear": "2014", "SchemeStatus": "reviewing", "Province": "Hebei Province" },{ "SchemeName": "Neiqiu Xing Kiln site protection greenhouses ", "SchemeType": "technical solution (delegated to a third party)", "DeclareYear": "2014", "SchemeStatus": "under review", "Province ": "Hebei province"}] TXT; print_r (json_decode ($ s, 1 ));
Array ([0] => Array ([SchemeName] => design scheme for ontology protection engineering of Hutian kiln site (Hulu Kiln, Horseshoe kiln) [SchemeType] => technical solution (delegated to a third party) [DeclareYear] => 2014 [SchemeStatus] => reviewing [Province] => Jiangxi Province) [1] => Array ([SchemeName] => yuanzhongdu ruins south gate of Gongcheng, south-west corner of the station Earth Protection Project [SchemeType] => technical solution (delegated to a third party) [DeclareYear] => 2014 [SchemeStatus] => reviewing [Province] => Hebei Province) [2] => Array ([SchemeName] => yuanzhongdu Site Environmental Remediation Project [SchemeType] => technical solution (delegated to a third party) [DeclareYear] => 2014 [SchemeStatus] => reviewing [Province] => Hebei Province) [3] => Array ([SchemeName] => [SchemeType] => technical solution (delegated to a third party) [DeclareYear] => 2014 [SchemeStatus] => reviewing [Province] => Hebei ))



Thank you!

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.