Convert Multidimensional PHP array to javascript array

后端 未结 4 1229
灰色年华
灰色年华 2021-01-12 11:23

I\'m trying to convert a PHP multidimensional array to a javascript array using the JSON encoder. When I do a var_dump, my php array looks like this:

array (         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-12 12:04

    You do not have to call parseJSON since the output of json_decode is a javascript literal. Just assign it to a variable.

    var tempArray = ;
    

    You should be able then to access the properties as

    alert(tempArray[0].Key);
    

提交回复
热议问题