Will
Will

Reputation: 91

How to create a chart in PHP using JSON data from SQL query

I have a sql query which creates a pivot table. Now I've have executed this query in PHP using 'multiquery' and have converted it into JSON using 'json_encode'. The JSON data is consists of around 25million records and the format of each record is

{
timestamp: .....;
value 1: .....;
value 2: .....;
value 3: .....;
value 4: .....;
..
..
..
value n: .....;
}

Now I need to create a chart from this. How should I convert the JSON data into dynamic array so as to create a chart. I'm using dygraphs library.

Upvotes: 0

Views: 541

Answers (2)

Reshma Mathew
Reshma Mathew

Reputation: 1

You can convert JSON string to array by using json_decode() function

$newArray = json_decode($json_string, TRUE);

Upvotes: 0

Thibaut
Thibaut

Reputation: 343

To convert your json to array you can use json_decode with "true" in second parameters: json_decode($json, true);

php doc

Upvotes: 1

Related Questions