Here you go...
PHP Code:
<?php
/********************************
Purpose: To calculate the distance between
two points on a map
$lat1 = latitude of first point
$lng1 = longitude of first point
$lat2 = latitude of second point
$lng2 = longitude of second point
********************************/
$lat1 = 37.391436;
$lng1 = -121.995964;
$lat2 = 37.385980;
$lng2 = -121.976737;
$theta = $lng1 - $lng2;
$distance = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$distance = acos($distance);
$distance = rad2deg($distance);
$miles = $distance * 60 * 1.1515;
$kilometers = $miles * 1.609344;
$nautical = $miles * 0.8684;
echo $miles;
?>