I want insert following checkbox in a row from database table, but have error, how is fix it? (I can not change 5 in name checkbox)
<input type="checkbox" name="checkbox_units_a[5][]" value="tv">
<input type="checkbox" name="checkbox_units_a[5][]" value="radio">
$name_un = $this -> input -> post('name_units_a');
$service_un = $this -> input -> post('checkbox_units_a');
$data3 = array();
foreach($name_un as $idx => $name) {
$data3[] = array(
'name_un' => $name_un[$idx],
'service_un' => json_encode($service_un[$idx]), ); //This is line 210
};
$this -> db -> insert_batch('hotel_units', $data3);
Error:
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 0
Filename: residence.php
Line Number: 210
My output in var_dump from $name_un:
array(1) {
[0] = > string(6)"accessories"
}
My output in var_dump from $service_un:
array(1) {
[5] = > array(2) {
[0] = > string(15)"tv" [1] = > string(12)"radio"
}
}
print_r($service_un);? - lc2817