如何在codeigniter中获取值数组?

How to get value post array in codeigniter? I have problem when I get value post array and echo the value. How to show post value when submit? here the error message:

A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: controllers/blablabla

view html:

<?php $i=0; foreach ($doc as $row) { ?>
<label>
<input name="size[<?php echo $i; ?>]" type="checkbox" value="<?php echo $row['doc']; ?>">&nbsp;&nbsp;<?php echo $row['doc']; ?>
</label>
<?php $i++; } ?>

controller :

$size = $this->input->post('size');
for ($i=0; $i<count($doc); $i++) 
{
   echo $size[$i];
}

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']; ?
  >">&nbsp;&nbsp;<?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']; ?>">&nbsp;&nbsp;<?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];
}