I am trying to populate a multidimensional array with CodeIgniter. In the code below, the outer foreach loops 2 times. The inner foreach loops 3 times and then 2 times. The problem I am having is that my resulting $data['tc'] contains a single array containing 5 items, but I want to end up with 2 arrays containing 2 and 3 items respectively.
$bd = $this->db->query("SELECT tbltc.BILLED FROM tbltc WHERE tbltc.PN = $pn AND tbltc.Y = $taxyear AND tbltc.SCENARIO = $scenario GROUP BY BILLED");
foreach ($bd->result() as $bdrow) {
$tcbd = $this->db->query("SELECT tbltc.BILLED, tbltc.TC, tbltc.CAT FROM tbltc WHERE tbltc.PN = $pn AND tbltc.Y = $taxyear AND tbltc.SCENARIO = $scenario AND tbltc.BILLED = '".$bdrow->BILLED."' GROUP BY TC");
foreach ($tcbd->result() as $row) {
$tmp[] = array( $row->BILLED => $row->TC);
}
$data['tc'] = $tmp;
}
Currently I am receiving an array that looks like this:
Array
(
[0] => Array
(
[2011-11-18 00:00:00] => C
)
[1] => Array
(
[2011-11-18 00:00:00] => I
)
[2] => Array
(
[2011-11-18 00:00:00] => S
)
[3] => Array
(
[2011-11-22 00:00:00] => C
)
[4] => Array
(
[2011-11-22 00:00:00] => S
)
)
But I need this to be broken into two separate arrays, one for the 2011-11-18 date, and one for the 2011-11-22 date.