Skip to content
Advertisement

How do you prevent tags from displaying in textarea?

I am saving this string into my sql db:

This displays fine in a table:

But when I display it in a textarea it shows up like this:

How can I get the textarea to keep the formatting but not show the <br> tags.

Advertisement

Answer

You would want to strip out the <br> tags and the extra space. Here’s a way to do it by splitting the array by <br>, trimming the array parts, then joining it back together with n.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement