Reputation: 53
I have a textarea
and I want to put <br/>
after every enter because I put the data in database. In database looks like this:
<pre>
Text
Text2
Text3
</pre>
The output in the page looks like
<pre>
TextTex2Tex3
</pre>
What can I do to put <br/>
if is clicked enter.. or if exist another solution.
Upvotes: 0
Views: 634
Reputation: 786
you should do something like this
echo str_replace("\n","<br>",$your_value);
you would get your result
Upvotes: 0
Reputation: 1630
When outputting the saved content, you can use the CSS rule white-space: pre;
on the element that will contain the content of the textarea
.
It's also safer than just outputting plain HTML content from your database.
Upvotes: 1