$string = \"My text has so much whitespace Plenty of spaces and tabs\"; echo preg_replace(\"/\\s\\s+/\", \" \", $string);
Replace Multiple Newline, Tab, Space
$text = preg_replace("/[\r\n]+/", "\n", $text); $text = preg_replace("/\s+/", ' ', $text);
Tested :)