Finding distances between two zip codes in PHP


I found this script to calculate distances between two zip codes from PHP (requires MySQL). According to this Idealog post, the calculation relies on a text file of Zip code lon/lats from CFDynamics, available on the downloads page.

I have yet to try it; however, I have a specific implementation that I was needing it for. Does anyone else have a better way to align searcher’s proximity to location-based data? I’d like to classify by city, but I’m sure that is a lot more of a gray area than allowing the searcher to specify a specific radius in which to search or letting the resource specify maximum distance to travel.

Added 2008.11.30:
I love Twitter. A few hours after posting this, I received a suggestion that I could get longitude/latitude from Google Maps.

On code.google.com, I found the following question: I need to convert addresses to latitude/longitude pairs. Can I do that with the Maps API?

Yes, this process is called “geocoding.” The Google Maps API provides two methods for performing geocoding. If you wish to geocode from within your Google Maps API application you can do so using the GClientGeocoder object. Alternatively you can send geocoding requests directly to the HTTP geocoder.

, ,

Leave a Reply

%d bloggers like this: