选择嵌套json中的单个值

时间:2018-09-26 01:13:10

标签: php json

给出提供的JSON,我只想提取纬度和经度坐标。

"vectorQuery": {
    "layers": {
        "50772": {
            "crs": {
                "type": "name",
                "properties": {
                    "name": "EPSG:4326"
                }
            },
            "field_names": ["id", "appellation", "affected_surveys", "parcel_intent", "topology_type", "statutory_actions", "land_district", "titles", "survey_area", "calc_area"],
            "type": "FeatureCollection",
            "features": [{
                "geometry": {
                    "type": "MultiPolygon",
                    "coordinates": [
                        [
                            [
                                [174.8592712667, -36.9675741167],
                                [174.8593271167, -36.9673525333],
                                [174.8593513167, -36.9672686333],
                                [174.8592025167, -36.9671776333],
                                [174.8591615833, -36.9672144833],
                                [174.8588608833, -36.9674851833],
                                [174.8592451667, -36.9678935833],
                                [174.8592699833, -36.9679199],
                                [174.8594188, -36.9680780333],
                                [174.8597915667, -36.9678483167],
                                [174.85991985, -36.9677692333],
                                [174.8599389, -36.96770445],
                                [174.8596869333, -36.9676552667],
                                [174.8596362667, -36.9676453833],
                                [174.8592712667, -36.9675741167]
                            ]
                        ]
                    ]
                },
                "distance": 0,
                "type": "Feature",
                "properties": {
                    "id": 5073537,
                    "appellation": "Lot 2 DP 64503",
                    "affected_surveys": "DP 64503",
                    "parcel_intent": "DCDB",
                    "topology_type": "Primary",
                    "statutory_actions": null,
                    "land_district": "North Auckland",
                    "titles": "NA20A/1419",
                    "survey_area": 3688.0,
                    "calc_area": 3686.0
                },
                "id": 995125
            }]
        }
    }
}

}

我实际上只是想获取坐标。我可以通过...选择这些。

    print_r($arr['vectorQuery']['layers']['50772']['features'][0]['geometry']['coordinates'][0][0]);

问题在于密钥50772可以更改每个请求。有没有直接遍历到坐标的方法?

0 个答案:

没有答案