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!