3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = ' <!--{hello}--> <div class="novalue"> <a>URL</a> </div> <!--{/hello}--> <!--{hello}--> <div class="novalue"> <a>URL</a> </div> <!--{/hello}--> <!--{hello}--> <div class="novalue"> <a>URL</a> </div> <!--{/hello}-->'; while(strpos($str, ' <!--{hello}-->') !== false){ $str = str_replace(" <!--{hello}-->", "<!--{hello}-->",$str); $str = str_replace(" <!--{/hello}-->", "<!--{/hello}-->",$str); } $str = str_replace(["<!--{hello}-->", "<!--{/hello}-->"], ["{hello}", "{/hello}"],$str); echo $str;

preferences:
31.72 ms | 405 KiB | 5 Q