assigning multidimensional php array to javascript array

前端 未结 5 1582
梦如初夏
梦如初夏 2021-01-17 02:29

I know this may be a duplicate, but I cant wrap my brain around the other examples. Help would be appreciated. I have a php array that i need to assign to a javascript array

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-17 03:03

    The way you are working with arrays is not correct.

    First you should initialize the array:

    var myArr = [];
    

    Then if you just want to add to the array, you can use push:

    myArr.push("something");
    

    or to a specific index:

    myArr[11] = "something";
    

    The syntax you are using is completely invalid.

提交回复
热议问题