- function compress_html($string) {
- $string = str_replace("rn", '', $string); //Clear newlines
- $string = str_replace("n", '', $string); //Clear newline characters
- $string = str_replace("t", '', $string); //Clear tab characters
- $pattern = array (
- "/> *([^ ]*) * ", //Remove the comment mark
- "/[s]+/",
- "//",
- "/" /",
- "/ "/",
- "'/*[^*]**/'"
- );
- $replace = array (
- ">\1<",
- " ",
- "",
- """ ,
- """,
- ""
- );
- return preg_replace($pattern, $replace, $string);
- }
Copy code
|