Does anyone have a php class, or regex to parse an address into components? At least, it should break up into these components: street info, state, zip, country
A library/language agnostic solution would be to use Google's geocoder for this. It can return detailed, broken-down information about a given address.
http://code.google.com/apis/maps/documentation/services.html#Geocoding%5FStructured
If you're talking about pre-existing data, good luck to ye. If this is something that you have control over the input for, I recommend creating separation of the different parts of the address at the input level. Jus' a suggestion.
Edit: Use this just as an example, if your data is all formatted very similarly. As Strager pointed out, in most cases there will be too much variation in data to use a regex effectively.
Assuming your input is of the format:
[Street Name], [State], [ZIP], [Country]
This regex will do the trick:
m/^(.+?),(.+?),([0-9]+),(.+)$/
But Regular Expressions are fairly complex...if you are going to use this for anything significant, I would suggest taking the time to learn Regexes. I have always found this cheat sheet very useful:
http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/
Here is a Python version using pyparsing for parsing street addresses. It's not PHP, but might give you some insights into the complexity of the problem.