Hope someone could help me. I'm new to web programming and I already spent hours to find the solution. I have to add php arrays (here $pu and $mArray) with JS. These arrays are multi-dimentional. I'd like to get the variable 'i' instead of the index '1' of the both arrays. I tried a lot without success. Help.
for (var i = 0; i < 4; i++) {
chart.addSeries({
name: '<?php echo $pu['1']; ?>',
data: [<?php echo join($mArray['1'], ', '); ?>]
});
A good approach is to output a JS array/object using PHP first.
var pu = <?php echo json_encode($pu) ?>
var mArray = <?php echo json_encode( $mArray ) ?>
Now run the JS loop etc.
for (var i = 0; i < 4; i++) {
chart.addSeries({
name: pu[i],
data: mArray[i]
})
}