I am having this function in my controller.
function get_data($year, $month) {
$query = $this->db->select('date,name,type')->from('books')->like('date', "$year-$month", 'after')->get();
$data = array();
$data2 = array();
$data3 = array();
foreach ($query->result() as $row) {
if ($row->name == 'AA' && $row->type == 'AM') {
$data[substr($row->date, 8, 2)] = '<div class="aa_am">' . $row->name . ' ' . $row->type . '</div>';
} else if ($row->name == 'AA' && $row->type == 'PM') {
$data2[substr($row->date, 8, 2)] = '<div class="aa_pm">' . $row->name . ' ' . $row->type . '</div>';
} else if ($row->name == 'BB' && $row->type == 'AM') {
$data3[substr($row->date, 8, 2)] = '<div class="bb_am">' . $row->name . ' ' . $row->type . '</div>';
}
}
return $data;
}
I want to retrieve all data which is in $data,$data1 and $data2 at the same time. Is it possible to do it?? If anyone have an idea it would be a help for me.
return array($data,$data2,$data3);, other option isreturn array_merge($data,$data1,$data2). array merge have chances of data lose in case of any key is same.