我正在尝试访问某个对象的属性,但它现在正在工作。这是完整的结果。
那么如何访问location对象中的lat属性呢?由于某种原因,它无法正常工作
SimpleXMLElement Object
(
[status] => OK
[result] => SimpleXMLElement Object
(
[type] => postal_code
[formatted_address] => Workington, Workington, Cumbria CA14 3QP, UK
[address_component] => Array
(
[0] => SimpleXMLElement Object
(
[long_name] => CA14 3QP
[short_name] => CA14 3QP
[type] => postal_code
)
)
[geometry] => SimpleXMLElement Object
(
[location] => SimpleXMLElement Object
(
[lat] => 54.6352139
[lng] => -3.5516768
)
[location_type] => APPROXIMATE
)
)
)
我正在尝试获取lat属性,但它无法正常工作
这就是我正在使用的
echo $result->result->geometry->location["lat"];
答案 0 :(得分:0)
结果应为
echo $result->result->geometry->location->lat;
不
echo $result->result->geometry->location["lat"];