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

Posted by axlq on 10/04/61 11:54

In article <Wt-dnSrpTKm-tEzZnZ2dnUVZ_rqdnZ2d@comcast.com>,
Chuck Anderson <websiteaddress@seemy.sig> wrote:
>flamer die.spam@hotmail.com wrote:
>> Ian Davies wrote:
>>> When I display large piece of text on a web page from a text field in my
>>> database the formatting such as paragraphs line feeds are lost, unless I
>>> include the appropriate html tags in it. How can I display the text as
>>> written initially?
>>
>> Perhaps <pre></pre> around the text.
>
>Or use nl2br($text) to convert line breaks to <br>.

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().

<pre>...</pre> is probably easier. If you don't want monospaced
font, you can always set the CSS font family for <pre> to sans-serif
or something.

-A

 

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

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