Reputation: 1816
I searched a lot about striping HTML tags from some particular database content(field). I got this code somewhere. It works fine. However it is for stripping all HTML tags except those tags that are specified.
But I want to strip tags which I specify and leave other tags as they are. How can I do so?
The code that I found for striping all tags except the provided ones is this:
<?php
echo strip_tags(nl2br($content), "<img><b><br><p><a>");
?>
Upvotes: 2
Views: 191
Reputation: 14532
strip_tags has also a second parameter where you can set all the tags you do not want to be removed.
That way it will only remove everything you don't want to keep.
http://php.net/manual/en/function.strip-tags.php
Upvotes: 1