title: How to pass php array of arrays to Javascript
body: <p>I have an array of arrays in PHP in this layout for example,</p>
  
  <blockquote>
    <p>"Key1" => { "id" => 1, "name" => "MyName", "address" => "USA" }<br>
    "Key2" => { "id" => 2, "name" => "MyName2", "address" => "Australia" }  </p>
  </blockquote>
  
  <p>The data in the PHP array was taken from SQL Database. Now I want to be able to use this in JavaScript.</p>
  
  <p>I searched the web and people are suggesting to use JSON using this code:  </p>
  
  <pre><code>var js_var = JSON.parse("&lt;?php echo json_encode($var); ?&gt;");
  </code></pre>
  
  <p>I get this error in firefox when using firebug  </p>
  
  <pre><code>missing ) after argument list [Break On This Error]
  var js_var = JSON.parse("{"Key1":{"id":"1","name":"MyName","address":"USA"...
  </code></pre>
  
  <p>Error is in right after <em>JSON.parse("{"Key1</em></p>
  
  <p>In google chrome, firebug does not report any errors</p>