I've got the following code:
$data = array(
"1421852400000" => "100",
"1421856000000" => "110",
);
$newData = json_encode($data);
echo $newData;
This is what comes out (using the PHP code above)
{"1421852400000":"100","1421856000000":"110"}
But what I really need is the array in this format:
[
[1421852400000, 100],
[1421856000000, 110],
[1421859600000, 125]
]
Also, the first value is a timestamp (being used in Flot charts) and the second value is for the y axis of the graph.
In javascript I get these values like this:
var visit = JSON.parse(xmlhttp.responseText);
When I simply display the desired format it works, but when I try the PHP things it's giving me some odd results..
The problem is that when I use a PHP array and encode it then echo that and fetch it with Ajax and parse it with js it's not in the right format and thus it does not work.. How would I get the desired result? Thanks in advance!