|
Posted by ZeldorBlat on 04/07/07 17:52
On Apr 7, 12:27 pm, Tyno Gendo <u...@example.com> wrote:
> 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 ;)
Why does everyone insist upon using regex's to do simple find/replace
operations?
str_replace("\n", " ", $someString);
[Back to original message]
|