assigning multidimensional php array to javascript array

前端 未结 5 1595
梦如初夏
梦如初夏 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条回答
  •  渐次进展
    2021-01-17 03:16

    You cannot use an integer as a variable name, like in this line: print "var 25[".$i."]=" .$result1['25'].";\n";. 25 cannot be a variable.

    If you want to map an array to a javascript object, you might want to take a look at json_encode

    EXAMPLE
    Your code could be written like this:

    
    
    

    looks much cleaner to me.

提交回复
热议问题