Skip to content
Advertisement

PHP, WordWrap how to cut only text and don’t cut html code

i have a problem.

wordwrap($getPagina[$i]["message"], 60, "<br/>", true)

I have to use the wordwrap function to not go too far with the text in a table. I inserted wordwrap and it worked fine but now that I also have to insert some html code I have a problem. The wordwrap function cuts my html code (for example span cuts it to me in sp and an) and it no longer works. How can I do to limit the wordwrap function to plain text only avoiding html codes? Thanks

Advertisement

Answer

You’ll want to use the strip_tags() function to remove HTML from your string.

wordwrap(strip_tags($getPagina[$i]["message"]), 60, "<br/>", true)
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement