As a follow up, I think the only reliable, clean way to manage is this is either:
1) Write your own HTML parser to strip out the comments or
2) Convert $content into a DOM tree and walk the tree looking for "comment" elements and remove them
Having said that, this gets you almost there for 90% of the cases:
$content = preg_replace('/<!(.*?)(--.*?--\s*)+(.*?)>/s', '', $content);
$content = preg_replace('/-->/', '', $content);
This one does 2 things differently:
1) It tries to be a little smarter about where and how it finds the beginning and end of comments and
2) it cleans up after itself for any nested comments that got missed.
Again, I would not recommend this for production code as it will break on any badly formatted HTML or unbalanced comments or other similiar silly things. Also, this does get rid of any Javascript script code that’s inside of comments (to hide it from older browsers). Whether this is a feature or a bug is debatable