you are here: codestackercodes [RSS]minify css using php

minify css using php

<?php
function optimizeCSS($text) {
	$text = preg_replace('~/\*.*?\*/~s','',$text); // comments
	$text = preg_replace('/[\r\n\t]/','',$text); // newlines and tabs
	$text = preg_replace('/ *(;|\:|\{|\}) */','$1',$text); // space before/after colons, semicolons and braces
	$text = str_replace(';}','}',$text); // remove final semicolon
	$text = trim($text);
	return $text;
}
?>

Comments