Return to Snippet

Revision: 46271
at May 16, 2011 05:21 by thefricky


Initial Code
/* Minify CSS */
function minifyCSS($string){
 
    /* Strips Comments */
    $string = preg_replace('!/\*.*?\*/!s','', $string);
    $string = preg_replace('/\n\s*\n/',"\n", $string);
 
    /* Minifies */
    $string = preg_replace('/[\n\r \t]/',' ', $string);
    $string = preg_replace('/ +/',' ', $string);
    $string = preg_replace('/ ?([,:;{}]) ?/','$1',$string);
    return $string;
}

Initial URL
http://kitmacallister.com/2011/minify-css-with-php/

Initial Description
As simple as it can be. An PHP minifier. All the credits go to his author, Kit MacAllister

Initial Title
Minify CSS With PHP

Initial Tags
css, php

Initial Language
PHP