Have some checkboxes, which I need to validate into format with '0' (unchecked) and '1' (checked).
<input type="checkbox" name="subcategory1[]" >Text 1<br>
<input type="checkbox" name="subcategory1[]" >Text 2<br>
<input type="checkbox" name="subcategory1[]" >Text 3<br>
I tried validate it with this code (found on internet):
$sc1 = "";
for($i=0; $i<=2; $i++)
{
if(isset($_POST['subcategory1'][$i])){ $sc1 .= '1'; }
else { $sc1 .= '0'; }
}
Firstly that works well, but when I add more checkboxes, this isn't working. It set all "1" at the begining of $sc1. Count them well.
Could be problem that they are in 3 divs (one div for one column), but still with same name?
Edit1: $sc1 chould looks like 010