This is a good example, directly affixed to the code, first of all to know the latitude value, longitude value
/**
* @desc calculates the distance * @param float $lat latitude value based on the longitude of two points *
@param float $lng Longitude value *
/function getdistance ($la T1, $LNG 1, $lat 2, $lng 2)
{
$earthRadius = 6367000;//approximate radius of Earth in meters/
*
Convert thes e degrees to radians to work with the
formula
*
/$lat 1 = ($lat 1 * PI ())/180;
$LNG 1 = ($lng 1 * PI ())/180;
$lat 2 = ($lat 2 * PI ())/180;
$LNG 2 = ($lng 2 * PI ())/180;
/*
Using the
haversine formula
http://en.wikipedia.org/wiki/Haversine_formula
Calculate the Distance
* *
$calcLongitude = $lng 2-$LNG 1;
$calcLatitude = $lat 2-$lat 1;
$stepOne = Pow (sin ($calcLatitude/2), 2) + cos ($lat 1) * cos ($lat 2) * POW (sin ($calcLongitude/2), 2);
$STEPTWO = 2 * ASIN (MIN (1, sqrt ($stepOne));
$calculatedDistance = $earthRadius * $STEPTWO;
Return round ($calculatedDistance);