Skip to content

Instantly share code, notes, and snippets.

View cybertiwari's full-sized avatar
🎯
Focusing

Sunil Tiwari cybertiwari

🎯
Focusing
View GitHub Profile
@cybertiwari
cybertiwari / calculateDistance.php
Created October 31, 2021 16:14
Calculate distance between two latitude and longitude in php using the Great-circle distance formulae
<?php
function calculateDistance($firstLatitude, $firstLongitude, $secondLatitude,$secondLongitude)
{
//get polar angle θ (theta) (angle with respect to polar axis)
$theta = $firstLongitude - $secondLongitude;
$radians = sin(
deg2rad($firstLatitude)
) * sin(