I'm getting an address input as one long string as opposed to name, address, city, state and zip. I split most of it up, besides for between the address and the city. So I want to search for any street type name (court, road, street, avenue, etc) and then split the string at the end of the word. Then I will be left with the address and city separate.
strpos()
only gives me the position of the beginning of the keyword, I want it to split at the end of the keyword.
For example this is where I'm up to:
John Doe
1 Main Street Anytown
NY
00000
I want to split between Street
and Anytown
. And this address won't be static, there may be more words etc.
Another idea would be a function that automatically splits a string into different fields. Someone told me that in some countries the postal service has an API that does it. Does USPS have such a thing? Their site doesn't indicate it.