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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.