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.
[php][file]http://w3lessons.info/wp-content/uploads/2011/12/calculate_distance1.txt[/file][/php]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”;
Thanks!!
Good Tutorial,
happy hday from Morocco ^^
Thanks!!
Good Tutorial,
happy hday from Morocco ^^