I have a feeling the answer is \"it\'s not possible,\" but thought I\'d ask to satisfy my curiosity.
I have some code that\'s echoed where the \\n is unavoidable:
<
Can't you do it like this:
$str = str_replace("\n", ' ', $str);
while (strpos($str, ' ') !== false) // while there's two spaces in a row
$str = str_replace(' ', ' ', $str);
Now $str
will have every spaces or \n
characters sequences replaced by only one space.
(because if you just remove \n you migth have some place where a space is missing, and if you just replace it by a space you'll have some places with multiple spaces in a row).
EDIT: i don't know if the loop is really necessary but i don't have anything to test here if str_replace
will automatically do the trick (and i don't think using regexp for such a simple thing is really a good idea).