- Remove text between two HTML comments.
$tmp_tpl = preg_replace(‘#(?<=<!–COMMENTBOX–>).+(?=<!–ENDCOMMENTBOX–>)#’, ”, $tmp_tpl);
Of course, to test this out, when you say echo $tmp_tpl, you won’t see anything, as these are comment tags (and thus do not display). So you would have to right-click and view source to see the ‘<!–COMMENTBOX–><!–ENDCOMMENTBOX–>’ effect.