|
$ String = trim (stripslashes ($ _ POST ['code']); // The stripslashes () function deletes escape characters (backslash)
If (! Empty ($ string )){
If ($ _ POST ['method'] = 'compressing '){
$ String = css_compress ($ string );
} Elseif ($ _ POST ['method'] = 'decompressed '){
$ String = css_decompress ($ string );
}
} Else {
$ String = '';
}
Function css_compress ($ string ){
// Compression
$ String = str_replace ("\ r \ n", "", $ string); // remove the line feed first.
$ String = preg_replace ("/(\ s * \ {\ s *)/", "{", $ string );
$ String = preg_replace ("/(\ s * \; \ s * \} \ s *)/", "}", $ string ); // remove the spaces and line breaks at the beginning of the parentheses and the last line;
$ String = preg_replace ("/(\ s * \; \ s *)/", ";", $ string );
Return $ string;
}
Function css_decompress ($ string ){
// Extract
$ String = css_compress ($ string); // before decompression, compress to the simplest state.
$ String = str_replace ("{", "\ r \ n {\ r \ n \ t", $ string );
$ String = str_replace ("}", "\ r \ n} \ r \ n", $ string );
$ String = str_replace (";", "; \ r \ n \ t", $ string );
$ String = str_replace ("*/", "*/\ r \ n", $ string );
Return $ string;
}
?>
Paste the css Code in the following box and select compression/Decompression
|