function distance_on_earth ($point1, $point2
{
$radius = 6371; // average radius of the earth in km
$lat1 = deg2rad$point1'latitude']);
$lat2 = deg2rad ($point2'latitude']);
$long1 = deg2rad ($point1'longitude']);
$long2 = deg2rad ($point2'longitude']);
return $radius * acossin$lat1)*sin$lat2) + cos$lat1)*cos$lat2) * cos$long2$long1));
}