我有点抓狂了,try 不同的东西.我有一些Geojson,并试图从它的信息与PHP.JSON如下所示:
{ "type": "Feature", "properties": { "PLAN_NO": "HP4002" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1.269204733799349, 60.69917889926522 ], [ -1.26900101889315, 60.708156244292169 ], [ -1.25068179301849, 60.708055130595085 ], [ -1.250890613767938, 60.699077822506901 ], [ -1.269204733799349, 60.69917889926522 ] ] ] }
},
{ "type": "Feature", "properties": { "PLAN_NO": "HP4003" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1.26900101889315, 60.708156244292169 ], [ -1.268797174460049, 60.71713348706259 ], [ -1.250472839496742, 60.717032336406525 ], [ -1.25068179301849, 60.708055130595085 ], [ -1.26900101889315, 60.708156244292169 ] ] ] }
}
$filename = 'test.json';
$data = file_get_contents($filename);
$features = json_decode($data, true);
我正在试着得到每一个的计划和坐标.我看到的所有json示例都有如下内容:
"properties": [ {"PLAN_NO": "HP002"}, etc ]
所以你可以这样做
foreach ($features as $feature) {
$plan = $feature['PLAN_NO'];
}
因为我的JSON格式有点不同,我不知道如何使用它.感谢您在正确方向上的任何指点.