Just building on top of my previous question here:
Rewriting a JSON string - grouping keys by value into a new array?
I am wondering how do I traverse the array given and resort it so that the output comes out something like this:
[{
"Name": "Title 1",
"Date": "2012-12-05",
"rows": [
{
"Subtitle": "Subtitle 1",
"Count1": 566,
"Count2": 105
},
{
"Subtitle": "Subtitle 2",
"Count1": 76,
"Count2": 15
}
]
},
{
"Name": "Title 2",
"Date": "2012-12-06",
"rows": [
{
"Count1": 66,
"Count2": 5
}...
where the original json array is grouped by "Name" column, and then sorted into multi-level structure like this (parent/multiple child json structure for properly building menu in our application)?
The original json data looks like this:
[{
"Name": "Title 1",
"Subtitle": "Subtitle 1",
"Count1": 556,
"Count2": 5,
"Date": "2012-12-05"
}, {
"Name": "Title 1",
"Subtitle": "Subtitle 2",
"Count1": 10,
"Count2": 100,
"Date": "2012-12-05"
}, {
"Name": "Title 3",
"Subtitle": "Subtitle 3",
"Count1": 798,
"Count2": 11,
"Date": "2012-12-04"
}...
and obviously I am looking for a solution in PHP, as I will read in the json data, process it and spit it out reformatted.