复选框始终返回一个值

i've got annoying problem with my checkbox.

Im getting name and value to checkbox from base (NAME:VALUE,NAME2:VALUE2,NAME3:VALUE3, etc). And I made code:

$count = count( $matches[0] );    
foreach($matches[0] as $match) {
$name_form = $matches[1][$i];
$form= '<tr><td class="head">Name</td><td>';
$value1 = explode(",",$values1); 
$n = count($value);
for ($y=0;$y<$n; $y++) 
{
$value2 = explode(":",$value1 [$y]); 
$form.= '<input type="checkbox" name="'.$name_form.'" value="'.$value2 [1].'"'.$selected.'>'.$value2 [0].'<br />';
}
$form.= '</td></tr>';
}

and I can't get values from this checkbox in array's. Everytime the script gives me just one, last checked value. I tried also foreach($_POST[$name_form]) as $name_form, it's just not working.

Everyone know what I can do?

Try adding '[]' at the end of the input's name:

$form.= '<input type="checkbox" name="input_name[]" value="'.$value2 [1].'"'.$selected.'>'.$value2 [0].'<br />';

Then access the checked values via

$checked = $_POST['input_name[]'];