line breaks in a textarea

Don’t do nl2br when you save it to the database. Do nl2br when you’re displaying the text in HTML. I can strongly recommend to not store any HTML formatting in the database (unless you’re using a rich HTML editor as well, in which case it would be silly not to).

A newline \n will just become a newline in the textarea.

Leave a Comment