- var_dump: documentation ( source)
- preg_match: documentation ( source)
<?php
$comment = '
<!--this is comment <!--and this as well and end-- of comment is!-->right now-->';
preg_match('/(\<!--\s*.*?((--\>)|$))/im', $comment, $matches);
var_dump($matches);