I want to insert data in table 'projects'. I have two arrays with different sizes, they are
$advisor_id = array(
'id' =>1
'id' =>2
'id' =>3
);
$project_id = array(
'pid'=>1
'pid'=>2
'pid'=>3
'pid'=>4
);
My code is:
$advisors = count($this->input->post('advisor_id[]'));
$PM_ids = count($this->input->post('PM_id[]'));
if($advisors > $PM_ids){
$count = $advisors;
}else{
$count = $PM_ids;
}
$data[] = array();
for($i =0; $i<$count ; $i++){
$data = array(
'advisor_id' =>$this->input->post('advisor_id')[$i],
'PM_id' =>$this->input->post('PM_id')[$i],
);
//print_r($data);
$this->db->insert_batch('project_config',$data);
}
My problem is the different sizes of arrays. How can I insert into database.