Jump to content

Assign PHP array to Javascript array ?


vacek

Recommended Posts

Hi,

 

For whatever reason (stupid) I cannot get my head wrapped around this.

 

I have 6 PHP arrays (data I grab from MySQL that is dynamic so might be one result, might be 60) that I need to assign to a javascript array so I can create graphs with the data.

 

PHP arrays are as follows:

$billable, $core, $available, $oto, $training, $name

 

The Javascript array needs to look like the following:

var items = [{
"Billable": 20,
"Core": 20,
"Available": 30,
"OTO": 20,
"Training": 10,
"Name": "Bob"
 },{
 "Billable": 20,
"Core": 30,
"Available": 20,
"OTO": 0,
"Training": 30,
"Name": "John"
},{
"Billable": 10,
"Core": 80,
"Available": 10,
"OTO": 0,
"Training": 30,
"Name": "Ralph"
   }];

I've been fiddling with this for some time, but cannot get it to work.

 

Any thoughts of a quick way to cycle through and build this javascript array ?

 

Thanks,

Link to comment
https://forums.phpfreaks.com/topic/287412-assign-php-array-to-javascript-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.