Skip to content
Advertisement

building a function that will generate this json [closed]

I am working on building a JSON for a morris graph and I am having a couple of problems.

this is the format I need to get:

JavaScript

I get these two values looping threw a single array and in every cycle, I can reed both of them.

I am adding this to tell anyone who can find this helpful that the best solution I could find is this:

JavaScript

this $chart_data than can be used as a feeding variable for the chart right away

Advertisement

Answer

JavaScript

Just loop through your items and create an empty object. After creating the empty object assign the values to an array and with json_encode make the array a json string

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement