I have a single location field where people can enter whatever they want, but generally they will enter something in the format of "Town, Initials". So for example, these entries...
New york, Ny
columbia, sc
charleston
washington, DC
BISMARCK, ND
would ideally become...
New York, NY
Columbia, SC
Charleston
Washington, DC
Bismarck, ND
Obviously I can use ucfirst()
on the string to handle the first character, but these are things I'm not sure how to do (if they can be done at all)...
- Capitalizing everything after a comma
- Lowercasing everything before the comma (aside from the first character)
Is this easily doable or do I need to use some sort of regex function?