I have a <textarea> where I am allowing user content to be submitted. I would like to allow a couple tags such as <b>, <i>,<blockquote>, and <del>. However, since the content will be displayed in the page, I have to ensure that there are no unclosed tags.
I know I can use strip_tags($textarea, '<b><i><blockquote><del>'), but how can I then ensure that all the remaining tags are properly closed?
You could use Tidy. It will clean and sanitize your HTML.
This comment, on php.net, address your problem and shows how to solve it: http://www.php.net/manual/en/tidy.examples.basic.php#89334