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)?
Using PHP, you could try:
<?php echo str_replace("'", "\'",$c);
PHP addslashes() function will help you: http://php.net/manual/en/function.addslashes.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With