Forgive me for the simplicity of this question but I am brand new to working with API's and JSON. But I have a JSON file and I want to print out the "text" value of "duration". How can I do that?
{
"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"
}
I am trying to do it using:
$url = 'https://maps.googleapis.com/maps/......'
$content = file_get_contents($url);
$json = json_decode($content, true);
echo $json['rows']['elements']['duration']['text'];
Many thanks!