【发布时间】:2015-12-31 18:32:23
【问题描述】:
请原谅我这个问题很简单,但我对使用 API 和 JSON 是全新的。但我有一个 JSON 文件,我想打印出“持续时间”的“文本”值。我该怎么做?
{
"destination_addresses" : [ "San Francisco, CA, USA" ],
"origin_addresses" : [ "Seattle, WA, USA" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "808 mi",
"value" : 1299998
},
"duration" : {
"text" : "12 hours 27 mins",
"value" : 44846
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
我正在尝试使用:
$url = 'https://maps.googleapis.com/maps/......'
$content = file_get_contents($url);
$json = json_decode($content, true);
echo $json['rows']['elements']['duration']['text'];
非常感谢!
【问题讨论】: