Open GoogleCodeExporter opened 9 years ago
Original comment by b...@mycnl.com
on 1 May 2012 at 9:44
<?php
function curl_request($sURL,$sQueryString=null)
{
$cURL=curl_init();
curl_setopt($cURL,CURLOPT_URL,$sURL.'?'.$sQueryString);
curl_setopt($cURL,CURLOPT_RETURNTRANSFER, TRUE);
$cResponse=trim(curl_exec($cURL));
curl_close($cURL);
return $cResponse;
}
$sResponse=curl_request('http://maps.googleapis.com/maps/api/distancematrix/json
',
'origins=04429&destinations=02135&mode=driving&units=imperial&sensor=false');
$oJSON=json_decode($sResponse);
if ($oJSON->status=='OK')
$fDistanceInMiles=(float)preg_replace('/[^\d\.]/','',$oJSON->rows[0]->elements[0]->distance->text);
else
$fDistanceInMiles=0;
echo 'Distance in Miles: '.$fDistanceInMiles.PHP_EOL;
Original comment by albrat...@gmail.com
on 30 Sep 2014 at 4:58
Original issue reported on code.google.com by
crose...@gmail.com
on 29 Apr 2012 at 3:19