How to convert a JSON multi-dimensional array to a JS multi-dimensional array PHPcode & lt ;? Php $ arr1 = array (& quot; a & quot;, & quot; B & quot;, & quot; c & quot ;); $ arr2 = array (how to convert a JSON multi-dimensional array to a JS multi-dimensional array
PHP code
JScript code
$. GetJSON ("../php/json. php? Parm = arr2 ", function (json) {// How to write in the middle });
If the final JS is
JScript code
var arr1=["a","b","c"]; var arr2=[ ["a1","a2","a3"], ["b1","b2","b3"], ["c1","c2","c3"] ]; var arr3=[ [ ["a11","a12","a13"], ["a21","a22","a23"], ["a31","a32","a33"] ], [ ["b11","b12","b13"], ["b21","b22","b23"], ["b31","b32","b33"] ], [ ["c11","c12","c13"], ["c21","c22","c23"], ["c31","c32","c33"] ] ];
------ Solution --------------------
I am not so familiar with js, so I want to know that all of them are passed to js. what should I do if I want to restore them to an array?
------ Solution --------------------
The getJSON method of jquery has converted the received data into a json object array.
That is to say, json in function (json) is a json object array.
You can use json. name directly.
In general, it is over when used up.
According to your description, it seems that you want to construct a global variable from it.
You can use for (k in json) to traverse each member and use the eval function to import it to the global variable.
Of course, you have to construct the variable name by yourself, because your php code is not passed out.