Created
August 23, 2015 20:12
-
-
Save gettocat/3dc67bcfc9b6dfb1132a to your computer and use it in GitHub Desktop.
compress html code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sanitize_output($buffer) { | |
$search = array( | |
'/\>[^\S ]+/s', // вырезаем после тегов все отступы, кроме пробелов | |
'/[^\S ]+\</s', // вырезаем перед тегами все отступы, кроме пробелов | |
'/(\s)+/s' // заменяем несколько пробелов одним | |
); | |
$replace = array( | |
'>', | |
'<', | |
'\\1' | |
); | |
return preg_replace($search, $replace, $buffer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment