php圧縮htmlコードの関数

1061 ワード

//   html
function compress_html($string) {
    $string = str_replace("\r
", '', $string); $string = str_replace("
", '', $string); $string = str_replace("\t", '', $string); $pattern = array("/> *([^ ]*) *</", "/[\s]+/", "/<!--[\\w\\W\r\
]*?-->/", "/\" /", "/ \"/", "'/\*[^*]*\*/'"); $replace = array(">\\1<", " ", "", "\"", "\"", ""); return preg_replace($pattern, $replace, $string); }

うまく説明しない