Alex Rivera | Logout

Capturing linebreaks (newline,linefeed) characters in a textarea

Asked 2008-11-14T03:29:36.203
19

I have a form with a <textarea> and I want to capture any line breaks in that textarea on the server-side, and replace them with a <br/>.

Is that possible?

I tried setting white-space:pre on the textarea's CSS, but it's still not enough.

Edit
Report

1 Answer

34

Have a look at the nl2br() function. It should do exactly what you want.

answered 2008-11-14T03:35:41.417

Your Answer