To remove, use the following code
$result = preg_replace('/\s+/', ' ',$text);The first parameter of the function is "\s". It matches any "whitespace" character: a space (" "), tab (t), newline (n), or carriage return (r).
Next comes the "+", which means one or more matches.
