|
Posted by Tyno Gendo on 04/07/07 16:27
Tyno Gendo wrote:
[snip]
> <?php
> $text="This is a line\r\nwith carriage\r\nreturns\r\nin it";
> echo "<pre>$text</pre>";
> $nocr=preg_replace("/\r\n/"," ",$text);
> echo "<pre>$nocr</pre>";
> ?>
Just thought, you may not have the \r as that's more a DOS thing anyway,
Unix will have just the \n, so you would need:
$nocr=preg_replace("/\r*\n/"," ",$text);
ie. zero or more "\r" rather than specifying it will have a \r\n as in
my previous post.
i'm not the most ingenious at regex, so anyone else have any comments on
this that would be great ;)
Navigation:
[Reply to this message]
|