my php function strip_tags is not working according to my expectations
<p>I am taking input as comments in my website. where i want few html tags to allow like</p>

<pre><code>  &lt;h2&gt;, &lt;h3&gt;, so on. . .
</code></pre>

<p>and few to ban.</p>

<p>But i am also using a function which check the part of string and replace it with smilies 
let us say '&lt;3' for heart and ':D' for lol </p>

<p>When i use function sanitizeHTML() which is following</p>

<pre><code>public function sanitizeHTML($inputHTML, $allowed_tags = array('&lt;h2&gt;', '&lt;h3&gt;', '&lt;p&gt;', '&lt;br&gt;', '&lt;b&gt;', '&lt;i&gt;', '&lt;a&gt;', '&lt;ul&gt;', '&lt;li&gt;', '&lt;blockquote&gt;', '&lt;span&gt;', '&lt;code&gt;', '&lt;img&gt;')) {
    $_allowed_tags = implode('', $allowed_tags);
    $inputHTML = strip_tags($inputHTML, $_allowed_tags);
    return preg_replace('#&lt;(.*?)&gt;#ise', "'&lt;' . $this-&gt;removeBadAttributes('\${1}1') . '&gt;'", $inputHTML);
}

function removeBadAttributes($inputHTML) {
    $bad_attributes = 'onerror|onmousemove|onmouseout|onmouseover|' . 'onkeypress|onkeydown|onkeyup|javascript:';
    return stripslashes(preg_replace("#($bad_attributes)(\s*)(?==)#is", 'SANITIZED ', $inputHTML));
}
</code></pre>

<p>It remove bad attributes and allow only valid tags  but when string like &lt;3 for heart come this function remove the part of string after &lt;3 .</p>

<p><strong>Note :</strong></p>

<p>The smilies code which do not have html special chars &lt; or > sign  work fine.</p>
