Firstly what I am trying is creating a pie chart using google chart api. There I have to feed an javascript array of array. Now what I have in server side is an php array of following structure:
[
{
"name": "a",
"price": 25200
},
{
"name": "b",
"price": 13500
}
]
What I need is:
[
[
"a": 25200
],
[
"b": 13500
]
]
What I have so far - used the following php function to convert.
public function convert($packages){
$packageShare = array(array());
$count = count($packages);
for($i = 0; $i < $count; $i++){
$pack = array();
$pack[$packages[$i]['name']] = $packages[$i]['price'];
$packageShare[$i] = $pack;
}
return $packageShare;
}
But the output was not what I want. Here is what the above function returns:
[
{
"a": 25200
},
{
"b": 13500
}
]
N.B. I need to feed this array in google chart api which takes something like this in javascript.
[ [0, 0], [1, 10], [2, 12] ]
What can be the standard way to feed?