I'm trying to do a forum in php. I have a problem. I have a publish form with a textarea. Let's imagine that I fill it all.
When I make a line break (when I press space bar), with nl2br, in my database there are <br>
tags added. But when I just type and there is an auto line break, there is no <br>
.
How can I do to, for example, at the end of 100 chars, there is an auto line break (that adds a <br>
in the database. I've tried in Javascript but I didn't found a correct answer.
With
Without
auto line break in textarea (no <br>
)
Problem:
` before you save the data in your database. Store the data as is and add any necessary changes when you output the data instead. You might want to display the data in some other way later, then it's better if it's clean in the database, or you will need to first clean the data and then format it for the new display. – M. Eriksson Jun 04 '22 at 08:56