Escaping apostrophe in JavaScript or PHP
escaping, javascript, php
Solution
Using PHP, you could try:
<?php echo str_replace("'", "\'",$c);
Problem
I have a foreach loop in PHP: ``` var circle_<?php echo $x; ?> = '<?php echo $c; ?>'; ``` It returns this in JavaScript: ``` var circle_0 = '<p class="medium">With us, you can customize more than just a closet.</p>'; var circle_1 = '<p class="medium">We are boutique condo builders who love what we do.</p>'; var circle_2 = '<p class="medium">who says condos can't be spacious?<br/></p>'; ``` As you can see, circle_2 has an apostrophe in the string, and as a result it breaks the script: Uncaught SyntaxError: Unexpected token ILLEGAL What filter would I use to fix this (PHP or JavaScript)?