I have an array coming from a SQL query that follows the following format:
[
["2012-10-01", 1, 3890],
["2012-10-01", 0, 8900],
["2012-09-21", 0, 8900],
["2012-09-21", 1, 8900],
...
]
At the end I want to have the counts for 0s and 1s. So for example, for the date 2012-10-01, I would have that the value 1 have a count 3890 and the value 0 have a count 8900. I want to know how I can iterate this array in order to build a final array like this:
$final_array["value0"]["2012-10-01"] = 3890
$final_array["value1"]["2012-10-01"] = 8900
$final_array["total"]["2012-10-01"] = 12790
Taking into account that it can happen that a date doesn't have a count for value 0 or 1, and the order of value 0 and 1 is not always the same.
So the first example could be like this:
[
["2012-10-01", 1, 3890],
["2012-09-21", 1, 8900],
["2012-09-21", 0, 8900],
...
]
As you can see the first date is lacking of value 0 and the final array would still have to have it like this:
$final_array["value0"]["2012-10-01"] = 3890
$final_array["value1"]["2012-10-01"] = 0
$final_array["value1"]["2012-10-01"]in your second example?