daily pastebin goal
39%
SHARE
TWEET

Minify CSS

CreativeJuiz Jan 10th, 2013 323 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function minCSS( $string ) {
  3.  
  4.         /* Kill comments */
  5.         $string = preg_replace('!/\*.*?\*/!s','', $string);
  6.         $string = preg_replace('/\n\s*\n/',"\n", $string);
  7.  
  8.         /* Minification */
  9.         $string = preg_replace('/[\n\r \t]/',' ', $string);
  10.         $string = preg_replace('/ +/',' ', $string);
  11.         $string = preg_replace('/ ?([,:;{}]) ?/','$1',$string);
  12.  
  13.         /* Remove Trailing Semicolon */
  14.         $string = preg_replace('/;}/','}',$string);
  15.  
  16.         return $string;
  17. }
  18. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top