I am trying to get the array of checkboxes within a form array. I am trying to get the data as the form array first then get the array of checkboxes within the array.
<form name="preview" id="post" action="" method="post">
<input type="hidden" name="category[$id]" />
<input type="checkbox" name="subcat[]" value="something" />
<input type="checkbox" name="subcat[]" value="somewhere" />
<input type="checkbox" name="subcat[]" value="something" />
<input type="checkbox" name="subcat[]" value="somewhere" />
<input type="hidden" name="category[$id]" />
<input type="checkbox" name="subcat[]" value="something" />
<input type="checkbox" name="subcat[]" value="somewhere" />
<input type="checkbox" name="subcat[]" value="something" />
<input type="checkbox" name="subcat[]" value="somewhere" />
<input class="button-primary" name="submit_preview" value="Submit Selected Tees" type="submit">
</form>
if (isset($_POST['submit_preview'])) {
foreach ( $_POST[ 'category' ] as $id ) {
foreach ( $_POST[ 'subcat' ][$id] as $subcat ) {
echo $subcat;
}
}
}