JSON Javascript AJAX jQuery HTML PHP Example MORE

How to parse and get google map direction api response


$origin      = "Rome, Italy";
 $destination = "Venice, Italy";
 $key = "YOUR-OWN-KEY";
 $url = "https://maps.googleapis.com/maps/api/directions/json?origin=".urlencode($origin).",IL&destination=" . urlencode( $destination) . "&sensor=false&key=" . $key;
 $jsonfile = file_get_contents($url);
 $jsondata = json_decode($jsonfile);
 print_r( $jsondata->routes[0]->legs[0]->distance);