可能重复:
如何使用减号访问对象属性?
我正在尝试解析 geo:point / geo:lat 但无处可去。这是我到目前为止的代码
$content = get_data('http://ws.audioscrobbler.com/2.0/?method=geo.getevents&location=united+kingdom&api_key=XXX&format=json&limit=10000&festivalsonly=1');
$LFMdata = json_decode($content);
foreach ($LFMdata->events->event as $event) {
$venue_lat = $event->venue->location["geo:point"]["geo:lat"];
$venue_long = $event->venue->location["geo:point"]["geo:long"];
JSON 将包含类似
"geo:point": {
"geo:lat": "52.7352",
"geo:long": "-1.695392"
}
有人知道吗?在 JavaScript 中看到了示例,但在 PHP 中没有看到