Created
June 20, 2014 05:03
-
-
Save goldsky/bebe23644630f39c9bc0 to your computer and use it in GitHub Desktop.
Output modifier to escape HTML for javascript's value
This file contains 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 | |
$output = $input; | |
$output = str_replace('/', '\/', $output); | |
$output = str_replace("\n", '', $output); | |
$output = preg_replace("/(>+(\s)*<+)/", '><', $output); | |
$output = preg_replace("/\s+/", ' ', $output); | |
return $output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment