[ create a new paste ] login | about

Link: http://codepad.org/uR4ohjUL    [ raw code | output | fork ]

PHP, pasted on Nov 14:
<?php

function sanitize_output($buffer) {

    $search = array(
        '/\>[^\S ]+/s',  // strip whitespaces after tags, except space
        '/[^\S ]+\</s',  // strip whitespaces before tags, except space
        '/(\s)+/s'       // shorten multiple whitespace sequences
    );

    $replace = array(
        '>',
        '<',
        '\\1'
    );

    $buffer = preg_replace($search, $replace, $buffer);

    return $buffer;
}

ob_start("sanitize_output");

/* regular html is started from here */
?>

<!DOCTYPE html>

<html>

           <head>

                      <title>Test page<title>

           </head>

           <body>

                      <h1>Welcome!</h1>

           </body>

</html>


Output:
1
<!DOCTYPE html><html> <head> <title>Test page<title> </head> <body> <h1>Welcome!</h1> </body></html>


Create a new paste based on this one


Comments: