Reply to Re: An Easy One for you all

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация