PHP has the built-in function strip_tags() for this purpose. strip_tags() function strips a string from HTML, XML, and PHP tags.
Syntax:
strip_tags(string,allow)
Parameters:
String – required and used for checking the string
allow – optional and used for specified allowed tags in string.
Example:
<?php
echo strip_tags(“<i>Hello </i> <b>world!</b>”,”<b>”);
?>
Output of this statement is ” Hello world! ” , Hello is not formatted italic because we only allow the <b> tag.
