php压缩html代码的函数

function compileMinify($value) {
    $replace = array(
        '/<!--[^\[](.*?)[^\]]-->/s'    => '',
        "/\n([\S])/"                => ' $1',
        "/\r/"                        => '',
        "/\n/"                        => '',
        "/\t/"                        => ' ',
        "/ +/"                        => ' ',
    );
    return preg_replace(array_keys($replace), array_values($replace), $value);
}

好用不解释

posted @ 2016-02-05 23:18  smismile  阅读(388)  评论(0编辑  收藏  举报