<?php
function distanceBetween($lat1, $lng1, $lat2, $lng2)
{
$r = 6371 * 1000; // Radio de la tierra para obtener metros
$dlong = deg2rad($lng2 - $lng1);
$dlat = deg2rad($lat2 - $lat1);
$a = pow(sin($dlat / 2), 2)
+ (
pow(cos(deg2rad($lat1)), 2)
* pow(sin($dlong / 2), 2)
);
$c = 2 * asin(min(1, sqrt($a)));
return $r * $c;
}
?>