Can someone please explain how to obtain this result from the following array? Here is the result I am looking for:
Array
(
[Nov 18, 2011] => Array
(
[C] => 2
[I] => 1
)
[Nov 22, 2011] => Array
(
[C] => 2
)
)
And here is the array with the raw data:
Array
(
[0] => Array
(
[0] => Array
(
[Nov 18, 2011] => C
)
[1] => Array
(
[Nov 18, 2011] => C
)
[2] => Array
(
[Nov 18, 2011] => I
)
)
[1] => Array
(
[0] => Array
(
[Nov 22, 2011] => C
)
[1] => Array
(
[Nov 22, 2011] => C
)
)
)
The first array shown represents the the count of items for each element of the inner array, which is what I am trying to summarize from the next array. Thanks.
- EDIT –
Here is the query which generates the above arra:
$qrybilled = $this->db->query("SELECT tbltc.BILLED FROM tbltc WHERE tbltc.PN = $pn AND tbltc.Y = $taxyear AND tbltc.SCENARIO = $scenario GROUP BY BILLED");
$x = 0; $arr_billed = array();
foreach ($qrybilled->result() as $row) {
$qry3 = $this->db->query("SELECT tbltc.* FROM tbltc WHERE tbltc.PN = $pn AND tbltc.Y = $taxyear AND tbltc.SCENARIO = $scenario AND tbltc.BILLED = '".$row->BILLED."' GROUP BY TC ORDER BY CAT ASC, TC ASC");
$tmp3 = array();
foreach ($qry3->result() as $row) {
$tmp3[] = array( date("M d, Y",strtotime($row->BILLED)) => $row->CAT);
}
$arr_billed3[] = $tmp3;
}
$data['billed3'] = $arr_billed3;
Array result: