PDA

View Full Version : Return in a Text Box as a New Line?



Niaad
April 19th, 2002, 16:33
I'm sure this is a very simple thing to do, since every major forum out there manages it.

All I want to do is make it so when somebody presses enter in a multiline text box, it actually shows up that way when it's saved to the database, and then displayed on a page.

I think this is done by reading where the user pressed the enter key, and then replacing that with a <br> tag (or \n). However, I'm not really sure how to go about making this work...

keith
April 19th, 2002, 16:37
$text = str_replace("\n", "<br>", $text);

megapuzik
April 19th, 2002, 16:59
$text = nl2br($text);


:biggrin2:

Niaad
April 19th, 2002, 17:48
I swear, there's a PHP function for everything... :)

Thanks!