I am trying to put my data inside Highchart Library. There it is showing sample as following code.
series: [
{
name: 'John',
data: [5, 3, 4, 7, 2]
},
{
name: 'Jane',
data: [2, 2, 3, 2, 1]
},
{
name: 'Joe',
data: [3, 4, 4, 2, 5]
}
]
So i need it to dynamically put as an Array for dynamic input (from PHP). So how can i make it a Javascript Array?
To use, for example:
series: myArray;
So how can i implement it with an array?
var myArray = new Array();
and .. ???
You can simply use the array literal (
[]) as in the example:which is equivalent to:
So
myArrayis an array of objects. These objects have two properties,nameanddata, where the latter is another array holding numbers.To send data from PHP to Javascript, you can create JSON from your PHP arrays using the
json_encode()function. For example, in your PHP, you can have something like this: