I have a field containing names of users. They comprise of the first and sencond names. When adding these to the database, I need to strip out all but 1 space between them so that I can check them for existing users already in the db.
For example, I enter Joe-Bloggs into the users, then enter Joe--Bloggs (dashes represent spaces). My code looks for exisiting users and misses Joe-Bloggs because the first one had only 1 space in it.
I've looked at preg_match and trim but it seems preg_match is designed to find characters/character strings while trim will only work for spaces at the beginning and end. I thought of using this too to add to the error checking of my code but if someone else could suggest an all-in-one function or a combination of 2?