-1

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

  • 1
    You should remove your `
    ` option. Also, this is not the way you should be formatting your string, you would do much better to [use CSS on your table](https://stackoverflow.com/questions/1258416/word-wrap-in-an-html-table) to wrap the words that way (and avoiding all the mess with HTML code). [See also](https://www.geeksforgeeks.org/how-to-wrap-table-cell-td-content-using-css/)
    – Martin Aug 26 '21 at 10:02
  • Possible duplicate of : https://stackoverflow.com/questions/1258416/word-wrap-in-an-html-table – Alive to die - Anant Aug 26 '21 at 10:13

1 Answers1

-1

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

wordwrap(strip_tags($getPagina[$i]["message"]), 60, "<br/>", true)
rovr138
  • 695
  • 6
  • 9
  • No. The tags probably need to be applied to style the text. And `strip_tags` can easily accidentally mess up strings if the HTML is not correctly formatted. – Martin Aug 26 '21 at 10:11
  • @martin Those are besides the point. The question is how to limit it to plaintext. – rovr138 Aug 26 '21 at 10:23