Background: I am attempting to run some addresses through an API to get GPS coordinates for routing purposes. The front end interface is simple. instead of dragging you through a description, here's a screen capture of it
easy-peasy, right? When the end user plops down his list of addresses and clicks submit, I explode the list into an array and replace all the spaces with %20 (the lookup API needs this format). Problem is that sometimes the lookup api doesn't like the city and kicks back a null set of data. easiest way to overcome this is to not send the city data in the first place since a ZIP code will suffice. how would I go about stripping it out? am I overthinking this? would it be more acceptable to ask the user not to put it in?
for reference, here is a dump oof an array after submission of data:
array(10) {
[0]=> string(50) "3464%20Edgewood%20Ave.%20Fort%20Myers%20FL%2033916"
[1]=> string(50) "2401%20Euclid%20Avenue%20Fort%20Myers%20FL%2033901"
[2]=> string(55) "2751%20Oak%20Street%20Fort%20Myers%20Beach%20FL%2033931"
[3]=> string(51) "2323%20Ford%20Street%20Fort%20Myers%20FL%2033916%20"
[4]=> string(56) "1200%20Homestead%20Rd%20N.%20Lehigh%20Acres%20FL%2033936"
[5]=> string(36) "13280%20Griffin%20Drive%20FL%2033913"
[6]=> string(52) "3400%20SW%2017th%20Place%20Cape%20Coral%20FL%2033914"
[7]=> string(58) "1601%20Skyline%20Drive%20North%20Fort%20Myers%20FL%2033903"
[8]=> string(56) "1800%20Unice%20Avenue%20N.%20Lehigh%20Acres%20FL%2033971"
[9]=> string(50) "3464%20Edgewood%20Ave.%20Fort%20Myers%20FL%2033916"
}
I've tried a str_replace()
as well as explode
ing the array to a multidimensional array with limited results as street and city names do not have a standard length, I'm thinking of trying a regex next, but I feel like it will be near impossible to cover all situations.