I want an array in Javascript, structure like this
$(function()
{
// prepare the data
for (var i=0; i<50000; i++) {
var d = (data[i] = {});
d["id"] = "id_" + i;
d["num"] = i;
d["title"] = "Task " + i;
d["duration"] = "5 days";
}
I want this array to be created through php. I already have the array there created by for loop
EDITED:
Is the above data in Javascript a multidimensional array, a simple array or a var?
is the structure saved in "d" or in data[i][id],data[i][title],... ?
ie, $data = array('item' => 'description', 'item2' => 'description2');
json_encode($data);
All you need
Use json_encode() to encode the array.
Access PHP variable in JavaScript That example works with arrays, too.