Forum Moderators: open
If it's coming from a database, use your php functions or, being the old schooler I am and like to see what it's doing, preg_replace. The double quotes are easy.
$content = preg_replace('/"/','"',$content);
So not you only have to worry about ' . if you use double quotes in your JS. no sweat, you shouldn't need to do anything at all. Otherwise, escape them:
$content = preg_replace("/'/","\\\\'",$content);
Memory's a little fuzzy on the backslash in PHP, which is why there's four there, you'll need to play with it. To properly get your output to have a literal backslash, like \' that, I recall having to use 4 - but this could be wrong.