- Instant help with your Php coding problems

Remove HTML tags from a string in PHP

Question:
How to remove HTML tags from a string in PHP?
Answer:
$text = '<div class="test"><p>Clean <a href="#">text</a></p></div>';

$cleanText = strip_tags($text);
Description:

To remove all HTML tags from a string, use the strip_tags function. This function tries to return a string with all NULL bytes, HTML, and PHP tags stripped from a given string.

 

Share "How to remove HTML tags from a string in PHP?"
Tags:
remove html tags, strip html tags, clean text from html
Technical term:
Remove HTML tags from a string in PHP
Interesting things
ChatGPT in a nutshell