You may want to consider using the PHP built-in function strip_tags, which does pretty much the same thing.
If you don't want to strip ALL html, but only the dangerous stuff, that is a lot more difficult, because there are more ways of doing things than you think.
The built-in strip_tags only removes unwanted ELEMENTS, not attributes. Attributes are just as bad, because they can be used to execute script etc. So strip_tags is only really useful to remove ALL tags.
It's not sufficient to remove script elements and attributes whose names start with "on".
One way I've done it in the past is to parse the HTML fragment into a DOM, remove anything not on a whitelist, then rebuild it into a valid HTML fragment. This also has the advantage that it beats exploits which use badly-formed HTML.
Whitelisting tags/attributes (rather than blacklisting) is a really good idea, because there are heaps of custom ones which some browsers support, which let people do BAD THINGS.
In general this is very difficult.
Mark