Return to Snippet

Revision: 60117
at October 21, 2012 13:34 by o0110o


Initial Code
function crush($_file) {
  $_file = preg_replace(array("/((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:\/\/.*))/","!/\*[^*]*\*+([^/][^*]*\*+)*/!"), "", $_file); /* remove comments */
  $_file = str_replace(array('
','\r','\t','\n','  ','    ','     '), '', $_file); /* remove tabs, spaces, newlines, etc. */
  /* remove spaces before/after certain characters */
  $_file = preg_replace(array('(( )+\))','(\)( )+)'), ')', $_file); $_file = preg_replace(array('(( )+\()','(\(( )+)'), '(', $_file);
  $_file = preg_replace(array('(( )+\})','(\}( )+)'), '}', $_file); $_file = preg_replace(array('(( )+\{)','(\{( )+)'), '{', $_file);
  $_file = preg_replace(array('(( )+\:)','(\:( )+)'), ':', $_file); $_file = preg_replace(array('(( )+\;)','(\;( )+)'), ';', $_file);
  $_file = preg_replace(array('(( )+\,)','(\,( )+)'), ',', $_file); return $_file;
}

Initial URL

                                

Initial Description
This function will compress any text-based content.

Initial Title
Compress any text-based content.

Initial Tags
css, javascript, php

Initial Language
PHP