I am trying to get the driving distance from google maps.
print_r($result); outputs the below:
Array
(
[0] => Array
(
[elements] => Array
(
[0] => Array
(
[distance] => Array
(
[text] => 3,936 km
[value] => 3935862
)
[duration] => Array
(
[text] => 1 day 18 hours
[value] => 150860
)
[status] => OK
)
)
)
)
my php code to produce this is:
$q = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=Sydney&destinations=Perth&mode=driving&sensor=false";
$json = file_get_contents($q);
$details = json_decode($json, TRUE);
$details=$details['rows'];
print_r($details);
I somehow need to access this array and get the distance text value, in this case 3936 km
Any help appreciated, Thanks as always