I am having a php string in the following format:
<pre>
$configOptions = "vCPUCores : '1 vCPU $3.00AUD',Ram : '0.5 GB $10.00AUD',PrimaryDrive : '50GB',DriveIOPs : '100'";
</pre>
I need to pass this string to analytics using javascript.
<script>
var configOptions = <?php echo $configOptions; ?>;
</scrip>
However, when the data is passed to analytics, the single quotes are replaced by the corresponding ascii codes -'
The output is obtained in the following format:
var configOptions = vCPUCores : '1 vCPU3.00AUD',Ram : '0.5 GB10.00AUD',PrimaryDrive : \'50GB\'
Here all the single quotes have got replaced ( when viewed through the browser source). This doesn't occur if I print the same in php. The issue occurs when the php data is passed to javascript.
I have tried several javascript and php encoding techniques regarding this, But none of them work.
Can anyone help me to fix this issue.