I want to replace multiple newline characters with one newline character, and multiple spaces with a single space.
I tried preg_replace("/
+/", "
", $text);
and failed!
I also do this job on the $text for formatting.
$text = wordwrap($text, 120, '<br/>', true);
$text = nl2br($text);
$text is a large text taken from user for BLOG, and for a better formatting I use wordwrap.