Join the DZone community and get the full member experience.Join For Free
To remove multiple occurences of whitespace characters in a string an convert them all into single spaces, use this:
Strip whitespace (or other characters) from the beginning and end of a string
$variable = trim($variable);
Opinions expressed by DZone contributors are their own.