I am trying to convert a multidimensional PHP array to a javascript array using a JSON encoder. When I do var_dump, my php array looks like this:
array (size=2) 'Key' => string 'a' (length=1) 'Value' => string 'asite.com' (length=9)
This is the code I'm using now to try and convert it to a JavaScript array:
var tempArray = $.parseJSON(<?php echo json_encode($php_array); ?>);
Whenever I run this code in a browser, the conversion output in the console is this:
var tempArray = $.parseJSON([{"Key":"a","Value":"asite.com"}]);
Is this the correct structure for a multidimensional javascript array? I ask because it keeps giving me this error in the line above:
SyntaxError: Unexpected token o
source share