function distance($lat1, $lon1, $lat2, $lon2, $unit) {
$theta = $lon1 - $lon2;
$miles = $dist * 60 * 1.1515;
if ($unit == "K") {
return ($miles * 1.609344);
} else if ($unit == "N") {
return ($miles * 0.8684);
} else {
return $miles;
}
}
echo distance
(32.9697,
-96.80322,
29.46786,
-98.53506,
"m") .
" miles<br>";
echo distance
(32.9697,
-96.80322,
29.46786,
-98.53506,
"k") .
" kilometers<br>";
echo distance
(32.9697,
-96.80322,
29.46786,
-98.53506,
"n") .
" nautical miles<br>";
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1554"></script>
0 comment about "Distance between two points (given the latitude/longitude of those points) in PHP"