How can I make php automatically add
at the end of each line in a text area?
I have a text form, and it posts messages to my website. However, if I want to go to a new line within that message, i.e. within that text area, I need to automatically add <br>. Is there someway of php detecting the end of a line and adding <br> automatically?
2 Responses to “How can I make php automatically add
at the end of each line in a text area?”


with out php you can
<textarea cols="20" rows="5" wrap="hard">
this will add a \n
Report this comment
Simple function called nl2br. Once you call the text from the form let say $_POST[text]
put it into new variable
$text_with_br=nl2br($_POST[text]);
and then echo it
echo $text_with_br;
Report this comment