How do I get the given 'distance' in JSON in this example?

Asked

Viewed 45 times

1

How do I get the given 'distance' in JSON in this example?

$url = "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=86015-810&destinations=86830-000&key=AIzaSyDL6_dJ-Mbi_03_g6lHhWibxY22Z2UeYZQ";

$json = file_get_contents($url);
$json_data = json_decode($json, true);

echo $json_data["text"];

1 answer

1


That echo should already solve your problem

$json_data['rows'][0]['elements'][0]['distance']

Browser other questions tagged

You are not signed in. Login or sign up in order to post.