How to get value post array in codeigniter?
Change the way name of checkbox written as follows,
<?php foreach ($doc as $row) { ?><label> <input name="size[]" type="checkbox" value="<?php echo $row['doc']; ? >"> <?php echo $row['doc']; ?></label><?php } ?>
And in post method,
$size_arr = $this->input->post('size');foreach($size_arr as $v){ echo $v;}
if for some reason it is not working then check with,
$size_arr = $_POST['size'];foreach($size_arr as $v){ echo $v;}
EDIT
One more alternative,
$arr = $this->input->post();$size_arr = $arr['size'];foreach($size_arr as $v){ echo $v;}
Core version,
$arr = $_POST;$size_arr = $arr['size'];foreach($size_arr as $v){ echo $v;}
Your html form code should be like below.
<input name="size[<?php echo $i; ?>]" type="checkbox" value="<?php echo $row['doc']; ?>">
Inside controller your code should be like below.
$size = $this->input->post('size');foreach($size as $sa) { echo $sa;}
No need to use $i in checkbox name in view file just take an array
View file
<?php foreach ($doc as $row) { ?><label><input name="size[]" type="checkbox" value="<?php echo $row['doc']; ?>"> <?php echo $row['doc']; ?></label><?php } ?>
Controller
$countsize = count($this->input->post('size'));for ($i=0; $i<$countsize ; $i++) { echo $this->input->post('size')[$i];}