get_distance

   function get_distance($lat1, $lat2, $long1, $long2)
    {
        $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=".$lat1.",".$long1."&destinations=".$lat2.",".$long2."&key= &mode=driving&language=pl-PL";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $response = curl_exec($ch);
        curl_close($ch);
        $response_a = json_decode($response, true);

        $status = "ERROR";
        $dist   = 0;
        $time   = 0;
        if($response_a['rows'][0]['elements'][0]['status'] === 'OK') {
            $dist   = $response_a['rows'][0]['elements'][0]['distance']['value'];
            $time   = $response_a['rows'][0]['elements'][0]['duration']['text'];
            $status = "OK";
        }

        return array('status' => $status, 'distance' => $dist, 'time' => $time);
    }
Enchanting Emu