-
- //Function name: compress_html
- //Parameters: $string
- //Return value: Compressed $string
- //by bbs.it-home.org
- function compress_html($ string) {
- $string = str_replace("rn", '', $string); //Clear newline characters
- $string = str_replace("n", '', $string); //Clear newline characters
- $string = str_replace("t", '', $string); //Clear tab characters
- $pattern = array (
- "/> *([^ ]*) *", //Remove comment marks
- "/[s]+/",
- "//",
- "/" /",
- "/ "/",
- " '/*[^*]**/'"
- );
- $replace = array (
- ">\1<",
- " ",
- "",
- """,
- """,
- " "
- );
- return preg_replace($pattern, $replace, $string);
- }
Copy code
|