- /**
- * Compress HTML: Clear line break, clear tab, remove comment mark
- * @param $string
- * The $string after @return compression
- * from:bbs.it-home.org
- * */
- function compress_html ($string) {
- $string = Str_replace ("\ r \ n", ", $string); Clear line break
- $string = Str_replace ("\ n", "", $string); Clear line break
- $string = Str_replace ("\ T", "', $string); Clear tabs
- $pattern = Array (
- "/> * ([^]*) * "/[\s]+/",
- "/ /",
- "/\" /",
- "/ \"/",
- "'/\*[^*]*\*/'"
- );
- $replace = Array (
- ">\\1<",
- " ",
- "",
- "\"",
- "\"",
- ""
- );
- Return Preg_replace ($pattern, $replace, $string);
- }
- ?>
Copy Code>>> You may be interested in the article:php stripped string newline instance parsing php compressed HTML (clear line breaks, clear tabs, remove comment marks) PHP form to convert textarea line breaks PHP regular filter HTML tags , spaces, line breaks, and so on. Php method for removing newline characters provides several ways to replace line breaks in PHP PHP generates Excel and controls line breaks in Excel cells |