This is an example for a form having a group of checkboxes besides a lot of other inputs:
$args = array(
'details' => array(
'name' => 'details[]',
'filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_REQUIRE_ARRAY
)
// ,
// a lot of other stuff here (all the form’s elements)
);
$myInputs = filter_input_array( INPUT_GET, $args, true );
where the checkboxes are (their form is in a page that reloads itself):
<label>
<input type="checkbox" name="details[]" value=“A” <?php if (in_array( “A”, $myInputs['details'] )) { echo 'checked'; } ?>>
Show A
</label>
<label>
<input type="checkbox" name="details[]" value=“B” <?php if (in_array( “B”, $myInputs['details'] )) { echo 'checked'; } ?>>
Show B
</label>
<label>
<input type="checkbox" name="details[]" value=“C” <?php if (in_array( “C”, $myInputs['details'] )) { echo 'checked'; } ?>>
Show C
</label>
<label>
<input type="checkbox" name="details[]" value=“D” <?php if (in_array( “D”, $myInputs['details'] )) { echo 'checked'; } ?>>
Show D
</label>