Published in: PHP
/* // example usage <script type="text/javascript"> var str = '<?= to_js_string($html) ?>'; </script> */ function to_js_string($str) { return str_replace(array("\\", "'", "\r", "\n"), array('\\\\', "\'", ' ', ' '), $str); }
You need to login to post a comment.
