When running this code it did not give any value.
But when replace lat lan value with (37.910689 ,-97.250977),(16.110560, -94.174805)
then it returns result in meters. It shows blank output when passed any other lat lan value then the USA address.
function location(){
$url="https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=28.666585,-77.229059&destinations=28.667053%2C-77.219898&key=Api key";
$json_string = $url;
$jsondata = file_get_contents($json_string);
$obj = json_decode($jsondata, TRUE); // Set second argument as TRUE
//print_r($obj['rows']); // Now this will works!
$prn=$obj['rows'];
foreach($prn as $row)
{
$ele=$row['elements'];
foreach($ele as $k)
{
$dis=$k['distance'];
foreach($dis as $l=> $lvalue){
$meter= $lvalue ;
}
}
}
return $meter ;
}