PHP检查是否未选中动态复选框

I have a form where a list is populated from a MySQL database and checkboxes are assigned for each one using the $index method.

When the form is posted, I then cycle through the checkboxes using the following

foreach ($_POST['check'] as $index => $value) {
    if (($_POST['check'][$index] == '1')) {

How could I check if none of the checkboxes are checked?

Checkboxes are not sent if not checked.

So, you can use if (!isset($_POST['check'])) {}

You can, for example, count number of checked checkboxes:

$counter = 0;

foreach ($_POST['check'] as $index => $value) {
    if (($_POST['check'][$index] == '1')) {
        // Do something

        $counter++;
    }
}

if ($counter == 0) {
    // Do something if no checkboxes are selected
}

Also you can just check if your $_POST['check'] is empty:

if (empty($_POST['check'])) {
    // Do something if no checkboxes are selected
}