Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function toJSString ($string) {
- $result='"';
- for ($i=0; $i<strlen($string); $i++) {
- if ($string[$i] == '"') {
- $result .= '\\"';
- } else if ($string[$i] == '\\') {
- $result .= '\\\\';
- } else {
- $result .= $string[$i];
- }
- }
- return $result.'"';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement