Php compresses html webpage code (clear spaces, line breaks, tabs, comment tags, etc.)
- /**
- * Html compression: clear line breaks, clear tabs, and remove comment tags
- * @ Param $ string
- * @ Return $ string after compression
- * From: bbs.it-home.org
- **/
- Function compress_html ($ string ){
- $ String = str_replace ("\ r \ n", '', $ string); // clear line breaks
- $ String = str_replace ("\ n", '', $ string); // clear the line break
- $ String = str_replace ("\ t", '', $ string); // clear the tab
- $ Pattern = array (
- "/> * ([^] *) * "/[\ S] + /",
- "/ /",
- "/\"/",
- "/\"/",
- "'/\ * [^ *] * \ */'"
- );
- $ Replace = array (
- ">\\ 1 <",
- "",
- "",
- "\"",
- "\"",
- ""
- );
- Return preg_replace ($ pattern, $ replace, $ string );
- }
- ?>
>>> Articles you may be interested in: php removes the string line break instance parsing php compresses html (clear line breaks, clear tabs, remove comment tags) php form conversion textarea linefeed method php regular expression filtering html tags, spaces, linefeeds and other code examples php method to remove linefeeds summary several php methods to replace linefeeds php excel generation and control Excel line breaks in cells |