Reply to Re: Line Breaks in a Textarea

Your name:

Reply:


Posted by Rik on 04/29/06 01:01

joelbyrd@gmail.com wrote:
> Didn't know exactly where to post this, but: How do I get line breaks
> in a textarea? I'm pulling text from a database, and this text
> definately has line breaks in it, because I
> replaced all the line breaks with <br /> tags ( using the php function
> nl2br() ), and <br /> tags showed up in the textarea.

GOOGLE: html textarea line-break

Further:
> this text definately has line breaks in it, because I replaced all the
line breaks with <br /> tags"

Do you mean: "this text has lost his line-breaks because I replaced them"?

Have you replaced all the line-breaks BEFORE adding it to the database (to
store html-code for example)? If so:
$string = str_replace("<br />", "<br />\n", $string);

Else: don't use nl2br() while displaying it in a textarea.

Compare the following code in your browser:
<textarea>this<br />is<br />some<br />text</textarea>
<textarea>this
is
some
text
</textarea>


Note:
"\n" works, '\n' doesn't, at least here on w2k with PHP 5.0.5, I have no
idea wether this is always the case.

Grtz,
--
Rik Wasmus

[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

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