Placing PHP array values into a javascript array? -


Is it a way I can loop through a PHP array and output data to a JavaScript array ?

For example, the JS script below will not work

  var mon_Loop =  

For me (i = 0; i & lt; mon_Loop; i ++) Because "I" is not a php variable, therefore PHP is invalid in the section, but one way is to show what I want to achieve. $ RowCount calculates the number of variable rows and then use for loop For example, for example, I want to keep the contents of the PHP array "javaScript array mon_Events [0] of" $ divMon [0] ".

I know That I can do it manually, like

  mon_Events [0] =  

But I have a lot and therefore a loop is needed, is there anything JS or PHP that can do this?

Cheers.

< Since it seems that your array has numerical indexes in $ divMon , you can use it to serial:

P>

  var array = & lt ;? php echo json_encode ($ divMon)? & Gt ;; // ...  

Comments