You are here: Re: Keeping the formatting of text « PHP Programming Language « IT news, forums, messages
Re: Keeping the formatting of text

Posted by Rik on 08/04/06 12:01

Geoff Berrow wrote:
> Message-ID: <earbtp$66m$2@blue.rahul.net> from axlq contained the
> following:
>
>> That converts line breaks to <br /> which doesn't validate as
>> HTML unless you do str_replace("<br />", "<br>", nl2br($text));
>> And doing that seems inefficient since nl2br() already performs
>> str_replace("\n", "<br />", $text). You may as well do the
>> str_replace yourself and ignore nl2br().
>
> Except that it's not always \n

preg_replace('/(\r\n|\r|\n)/','<br>',$string);

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this 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

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