I have a form that someone can enter in a city and state or a zip code. I’m trying to take that entry and determine a zip code for it so I can find the surrounding zip codes. Does anyone have any good logic that they’ve used to do this? I’m thinking people could enter in the following entries.
- chicago, il
- chicago il
- 60601
- st. louis, mo
- st louis, mo
- st louis mo
I was thinking of using explode but based on the different entries I’m not sure I can do that. Any ideas? Thanks!
Easier way in my opinion would be to just use google geocoding api and get the contents of eg: http://maps.googleapis.com/maps/geo?q=st.%20louis%20mo&output=json (Seems the url has some hotlink protection of something, copy paste the link to view the actual output)
You get everything in a json format, or xml if you wish – and get all the info you need.
http://code.google.com/apis/maps/documentation/geocoding/