Over a million developers have joined DZone.

Distance Calculation Using Latitude And Longitude In PHP

ZIPCodeWorld.com provides this routine to calculate the distance between two points (given the latitude/longitude of those points) in PHP. It is being used to calculate distance between two points lat1, long1 and lat2, long2 and uses radius of earth in kilometers or miles as an argurments using our ZIPCodeWorld(TM) and PostalCodeWorld(TM) products which offer the United States ZIP codes, Canadian Postal Codes, Mexican Postal Codes and North American Area Codes database subscription and solution services.

echo distance(32.9697, -96.80322, 29.46786, -98.53506, "k") . " kilometers
"; echo distance(32.9697, -96.80322, 29.46786, -98.53506, "n") . " nautical miles
"; ?>

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}