Textarea not respecting line breaks

547 Views Asked by At

I'm having a problem with a textarea.

I'm using BBPress of Wordpress. When I public a post, it looks like this on the DB:

text text text
text text 
 
[center]text text text[/center]

text text text

But When I try to edit this post on the textarea it looks like this:

text text text
text text
[center]text text text[/center]
text text text

If I save the post it will lose the <br> and the <p></p> The output changes from:

<p>text text <br> text text</p><p></p><p>text text text</p>

To:

<p>text text text text</p><p>text text text</p>

So.. What I need is to retrieve the data of the DB and put it into the textarea without losing those line breaks?

It was working fine but I don't know what happened. :|

If someone could give me a clue I would be grateful : )

Thanks

2

There are 2 best solutions below

0
On BEST ANSWER

I found the problem.

It was the function that minify the HTML.

That was making my textarea lose the line breaks.

1
On
text text text
text text 
text text text
text text text

Using textarea if you break words. You can try function nl2br() in php