code:
<?php
$this->db->select('*');
$this->db->from('student');
$this->db->order_by('studentID','DESC');
$sql1 = $this->db->get();
$result1 = $sql1->result_array();
foreach($result1 as $arr1)
{
$array1[] = array(
'link' => 'student',
'values' => '<b>'.$arr1['create_username'].'</b> added new student <b>'.$arr1['name'].'</b>',
'dates' => $arr1['s_date']
);
}
$this->db->select('*');
$this->db->from('professor');
$this->db->order_by('professorID','DESC');
$sql2 = $this->db->get();
$result2 = $sql2->result_array();
foreach($result2 as $arr2)
{
$array2[] = array(
'link' => 'professor',
'values' => '<b>'.$arr2['create_username'].'</b> added new professor <b>'.$arr2['name'].'</b>',
'dates' => $arr2['s_date']
);
}
$this->db->select('*');
$this->db->from('classes');
$this->db->order_by('classesID','DESC');
$sql3 = $this->db->get();
$result3 = $sql3->result_array();
foreach($result3 as $arr3)
{
$array3[] = array(
'link' => 'classes',
'values' => '<b>'.$arr3['create_username'].'</b> added new course <b>'.$arr3['name'].'</b>',
'dates' => $arr3['s_date']
);
}
foreach(array_combine($array1,$array2,$array3) as $rowss)
{
echo '<li>
<a href="'.base_url().''.$rowss['link'].'">
<p>'.$rowss['values'].'</p>
</a>
<a href="javascript:void(0)">'.time_elapsed_string($rowss['dates']).'</p>
</li>';
}
In this code I am simply run three query simultaneously for table student, professor and classes. Now, I want to combine or map all array i.e. array1, array2, array3 which is inside the foreach loop into one single array. So, How can I resolve this? Please help me.
Thank You
array_merge($array1,$array2,....)