Judging from the sheer number of "holes" found in the posted samples, clearly, creating "safe" html is a difficult task.

Consider an alternative (html to text) from Tom:
[url]http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/striphtml.gz[/url]

FYI, I noticed that no one has yet reported a flaw in inputCheck() from charlieNOSPAM's. It missed the case:

<img src="http://.com/transparent.gif" width=300 height=300 onmouseover="alert('hello')"

By dropping the trailing '>', the tag isn't uppercased, and then fails to match the rule (supposing that "IMG" was added to the list of tags to disable).

Most badhtml2safehtml() functions seem to miss the possibility of mixed case in the tags name, dangerous attributes, or malformed HTML that still executes something dangerous in a forgiving web browser.
----
Manual Page -- [url]http://www.php.net/manual/en/function.strip-tags.php[/url]
Edit Note -- [url]http://master.php.net/manage/user-notes.php?action=edit+33993[/url]
Delete Note -- [url]http://master.php.net/manage/user-notes.php?action=delete+33993&report=yes[/url]
Reject Note -- [url]http://master.php.net/manage/user-notes.php?action=reject+33993&report=yes[/url]