Is it possible to strip everything that is not valid HTML markup (including comments) from a variable without regex - any hidden function like strip_tags but the opposite?
$var = "<html>" .
"<head>" .
"<script src="something"></script>" .
"<script>document.write('Hello');</script>" .
"<p>Some text</p>" .
"<!-- Comment -->" .
"Random text not in any markup." .
"</html>";
I would want $var to contain after processing:
<html>
<head>
<script src="something"></script>
<script>document.write('Hello');</script>
<p>Some text</p>
</html>