CSS Input


Code:

<?php

function optimize($css) {    
    $css = preg_replace('~/\*.*?\*/~s','',$css);        // comments
    $css = str_replace(array("\n","\t","\r"),'',$css);  // newlines and tabs
    $css = preg_replace('/: */',':',$css);              // space after colons
    $css = preg_replace('/ *(;|\{|\}) */','$1',$css);   // space before/after semicolons and braces
    $css = str_replace(';}','}',$css);                  // remove final semicolon
    $css = trim($css);                                  // trim leading and trailing whitespace
    return $css;
}