- preg_replace: documentation ( source)
<?php
$html = <<<EOT
<div>
<p>Hello World</p>
<!--
<table class="123456789132456789123456789123456789123456789">
<tr class="">
<!--<td></td>-->
<!--<td></td>-->
<td class="123456789123456789123456789123456789123456789">FooBar</td>
</tr>
</table>
-->
</div>
EOT;
do {
$html = preg_replace("/<!--(?(?!<!--).)*-->/sU", '', $html, -1, $count);
} while ($count);
echo $html;