IAL32

Output Clean Buffer

Nov 14th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. ob_start('cleanOutput');
  2. function cleanOutput($buffer) {
  3.     $search = array(
  4.         '/\>[^\S ]+/s', //strip whitespaces after tags, except space
  5.         '/[^\S ]+\</s', //strip whitespaces before tags, except space
  6.         '/(\s)+/s'  // shorten multiple whitespace sequences
  7.     );
  8.     $replace = array(
  9.         '>', '<', '\\1'
  10.     );
  11.     $buffer = preg_replace($search, $replace, $buffer);
  12.     return $buffer;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment