php实现把html压缩输出(页面一行代码)
php实现把html压缩输出(页面一行代码)函数代码:
<?php
$a=file_get_contents('html文件.html');
function Compress_Html($string){
return trim(preg_replace(array("/> *([^ ]*) *</","/<!--[^!]*-->/","'/\*[^*]*\*/'","/\r\n/","/\n/","/\t/",'/>[ ]+</',"/\s(?=\s)/"),array(">\\1<",'','','','','','><',''),$string));
}
echo compress_html($a);
页:
[1]