![php](https://habrastorage.org/r/w120/files/373/e8b/dd3/373e8bdd3cb644d3bbeba47d34d1876d.png)
PHP
- 6 ответов
- 0 вопросов
1
Вклад в тег
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);
/* Kill Trailing Semicolon, Contributed by Oliver */
$string = preg_replace('/;}/','}',$string);
/* Return Minified CSS */
return $string;
}