JavaScript:
var chartData = [];
for (var i = 0; i< data.prices.length; i++)
{
chartData.push
({
"date": data.prices[i][0],
"value": data.prices[i][1],
"volume": data.total_volumes[i][1]
});
}
My attempt (PHP):
$chartData = [];
$length = count($data->prices);
for ($i = 0; $i < $length; $i++)
{
$chartData[] = array($data->prices[$i][0],$data->prices[$i][1],$data->total_volumes[$i][1]);
}
I'm trying to handle data from an API server side with php and then encode the data for javascript. I'm stuck converting this javascript snippet to PHP at the "date": "value": and "volume": I don't know what the equivalent to this would be in PHP. It looks as though they are labels in javascript to the data being pushed to the array? How do I give the data being pushed to the array the same labels in PHP?