Page 1 of 1
Retaining carriage returns in textarea boxes
Posted: Thu Feb 10, 2005 1:04 pm
by voltrader
How do I correctly format for carriage returns input into textarea boxes?
For example, if a user entered two lines separated by pressing the "enter" key, the text is POSTed without the line feeds.
How do I retain the line feeds?
Posted: Thu Feb 10, 2005 1:24 pm
by onion2k
The carriage returns are there, just that when you output the text in html they're ignored (HTML ignores whitespace). Use nl2br() to convert them into <br /> tags.
Posted: Thu Feb 10, 2005 2:21 pm
by Chris Corbyn
Wow I didn't know such a function existed!!! I've been writing functions to convert certain features to html for the past year. Grrrr

Posted: Thu Feb 10, 2005 5:23 pm
by timvw
That is why i love this forum
Discover new functions (or situations where a function comes in handy) every day.
Posted: Thu Feb 10, 2005 6:03 pm
by RobertGonzalez
If you visit the php.net website
function definition for nl2br() and check the comments there is a link to a beefed up version of nl2br().
I believe it is at
this web address. It is a pretty good function that I have used in several applications.