I have some rather long string containing just about anything that I want to convert to JSON from PHP. Is there a simple way to do this? For example I would like this JSON ouput to work:
<?php
$var = "hel\"lo";
$var2 = "hel\nlo";
echo "[\"".$var."\", \"".$var2."\"]"; // should give me the data: hel"lo and hel<new line>lo
?>
json_encode()