- htmlentities: documentation ( source)
- preg_quote: documentation ( source)
- preg_replace: documentation ( source)
<?php
$content="aaa <!--[if (gt IE 9)|!(IE)]><!--> <html lang=\"en\"> <!--<![endif]--> bbb";
$tagOpen="<!--[if (gt IE 9)|!(IE)]><!-->";
$tagClose="<!--<![endif]-->";
$condition='/'.preg_quote($tagOpen).'(.*)?'.preg_quote($tagClose).'/i';
$content=preg_replace($condition, '$1', $content);
echo htmlentities($content);