Distance between two points with lat and lng
<?php
function distanceLatLng($a, $b)
{
list($lat1, $lon1) = $a;
list($lat2, $lon2) = $b;
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$meters = ($dist * 60 * 2 * 1000) * 1.2; // 20% de curva
return $meters;
}