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.
Reference:
PHP strip_tags reference
Share "How to remove HTML tags from a string in PHP?"
Related snippets:
Tags:
remove html tags, strip html tags, clean text from html Technical term:
Remove HTML tags from a string in PHP