How to insert multidimensional array to database in CI?
Please try the below code,
function insertUploadedFiles($data){ foreach ($data['file_name'] as $key => $fileData){ $datas[] = array( 'customer_id' => $data['customer_id']['customer_id'], 'file_name' => $fileData, 'file_path' => $data['file_path'][$key] ); } $this->db->insert_batch('t_customer_file_ref', $datas);}
I assume that both the file_name and file_path elements will have same indexes like 0, 1, 2 etc.,