Improve best php html obfuscator and compress

here it’s my php function for compress and obfuscater html string.
i need help to improve it with you.
please correct it if have any problem or better performance.


<?php

$a = "<html>
	<body>
		<p>this is <b>X</b> element that i like it</p>
	</body>
</html>";

function obfuscater($html)
{
	preg_match_all("!(<(?:code|pre|textarea).*>[^<]+</(?:code|pre|textarea)>)!", $html, $pre);
	$pattern = array(
		"!<(?:code|pre|textarea).*>[^<]+</(?:code|pre|textarea)>!",
		"/\\r\
/",
		"/[\	\
]+/",
		"/[\\s]+/",
		"/\\<\\!\\-\\- .* \\-\\-\\>/",
	);
	$replacement = array(
		"#pre#",
		"\
",
		" ",
		" ",
		"",
	);
	$html = preg_replace($pattern, $replacement, $html);
	if(!empty($pre[0])) foreach($pre[0] as $tag) $html = preg_replace("!#pre#!", $tag, $html, 1);
	return $html;
}

echo obfuscater($a);
?>

out put is :


<html> <body> <p>this is <b>X</b> element that i like it</p> </body> </html>

that must be :


<html><body><p>this is <b>X</b> element that i like it</p></body></html>

just don’t forget the space between some tags must be exist because the page structure will be damaged.

what a about google!
google do this !

For better performance…don’t do this?

Google also writes non-validating code. Either way, Google does not use your flawed “HTML Compressor”.