I'm trying to write a code which removes all white spaces but keeps paragraphs instead.
I have this code:
$replaced = preg_replace('/\s\s+/', ' ', "1st. line
2nd. line goes here
3rd. line goes there");
echo $replaced;
As an output I get:
1st. line 2nd. line goes here 3rd. line goes there
But it should be like this:
1st. line
2nd. line goes here
3rd. line goes there
nl2br() function isn't a good solution for me, because I need to put this output in a textarea.