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

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"];
    
asked by anonymous 13.04.2018 / 20:27

1 answer

1

This echo should solve your problem

$json_data['rows'][0]['elements'][0]['distance']
    
13.04.2018 / 20:48