I recently discovered a strip_tags() function that takes a string and a list of accepted html tags as parameters.
Suppose I wanted to get rid of the images in a row, here is an example:
$html = '<img src="example.png">'; $html = '<p><strong>This should be bold</strong></p>'; $html .= '<p>This is awesome</p>'; $html .= '<strong>This should be bold</strong>'; echo strip_tags($html,"<p>");
returns this:
<p>This should be bold</p> <p>This is awesome</p> This should be bold
therefore, I got rid of my formatting through <strong> and possibly <em> in the future.
I want to use a blacklist, not a whitelist:
echo blacklist_tags($html,"<img>");
return:
<p><strong>This should be bold<strong></p> <p>This is awesome</p> <strong>This should be bold<strong>
Is there any way to do this?
source share