I am trying to access a PHP variable in JavaScript. I've escaped quotes in the PHP variable and the JavaScript won't pick it up. Without changing the $a1 php variable, how can I access it in JavaScript?
<?php
$a1 = "Here is the \"best\" apple around"; //<-- doesn't work in javascript...
$a2 = "Here is the best apple around"; //<--works fine in javascript...
?>
JavaScript:
<script type="text/javascript">
var str = "<?php echo $a1; ?>";
alert(str);
</script>