Codeigniter相同的输入名称数组

I am working on this application which i need to achieve something like this, in the system we are allowing the system administrator to add customers and their vehicles,

Customers can have one or more vehicles, by default there are 8 fields to add the information of customer's vehicle i have named all the input fields as "vehicle[]"

ex: <input type="text" name="vehicle[]" placeholder="" class="form-control name_list" />

all the input fields goes by the name "vehicle[]".

this is my interface

by clicking "Add another" user will get another set of same fields (same 8 default fields ) this also has the same name of "vehicle[]".

what i want to do is insert all the vehicle information to vehicles table in my database. columns Vehicle number to vehicle_number so on.

how can i handle though an array or some other method.

Make your form like this

<input type="text" name="vehicle[vehicle_no][]" placeholder="" class="form-control name_list" />
<input type="text" name="vehicle[make][]" placeholder="" class="form-control name_list" />
<input type="text" name="vehicle[model][]" placeholder="" class="form-control name_list" />
<input type="text" name="vehicle[chassis_no][]" placeholder="" class="form-control name_list" />
<input type="text" name="vehicle[engine][]" placeholder="" class="form-control name_list" />
<input type="text" name="vehicle[color][]" placeholder="" class="form-control name_list" />
<input type="text" name="vehicle[type][]" placeholder="" class="form-control name_list" />
<input type="text" name="vehicle[battery][]" placeholder="" class="form-control name_list" />

so in CI you can access it like:-

$postedData = $this->input->post();
$objectToinsert = array()
for($postedData['vehicle']['vehicle_no'] as $key => $vehicle){
     //This is how you can get individual record
     $objectToinsert['vehicle_no'] = $postedData['vehicle']['vehicle_no'][$key];
     $objectToinsert['make'] = $postedData['vehicle']['make'][$key];
     $objectToinsert['model'] = $postedData['vehicle']['model'][$key];
     $objectToinsert['chassis_no'] = $postedData['vehicle']['chassis_no'][$key];
     so on.................
     $this->db->insert('vehicle', $postedData);

}