Here is a very handy function, which calculate the distance from a point A to a point B, using latitudes and longitudes. The function can return the distance in miles, kilometers, or nautical miles.

[file]http://w3lessons.info/wp-content/uploads/2011/12/calculate_distance1.txt[/file]

Usage

Using the function is pretty simple: All you need to do is to call it. Parameters are: from latitude, fromlongitude, to latitude, to longitude and unit, which can be m for miles, k for kilometers, and n for nautical miles

//Miles echo calculate_distance(32.9697, -96.80322, 29.46786, -98.53506, “m”) . ” miles”;

//Kilometers echo calculate_distance(32.9697, -96.80322, 29.46786, -98.53506, “k”) . ” kilometers”;

//Nautical miles echo calculate_distance(32.9697, -96.80322, 29.46786, -98.53506, “n”) . ” nautical miles”;

karthikeyanPHPdistances,phpHere is a very handy function, which calculate the distance from a point A to a point B, using latitudes and longitudes. The function can return the distance in miles, kilometers, or nautical miles.UsageUsing the function is pretty simple: All you need to do is to call it. Parameters...PHP, HTML5, CSS, jQuery, Angular, Facebook Style Scripts & demos

Related Posts