Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mehedimuaz/1be7390740caec217a6f6bac13ec9472 to your computer and use it in GitHub Desktop.
Save Mehedimuaz/1be7390740caec217a6f6bac13ec9472 to your computer and use it in GitHub Desktop.
function distanceGeoPoints ($long1, $lat1, $long2, $lat2) {
$lat = deg2rad($lat2 - $lat1);
$long = deg2rad($long2 - $long1);
$a = sin($lat/2) * sin($lat/2) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * sin($long/2) * sin($long/2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$d = 6371 * $c;
return $d;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment