显示数组中复选框的名称

I'm attempting to display the names of my checkboxes with the foreach statement below, but all I'm getting is "on" for each one checked. I've got the code for one of the checkboxes and was wondering if there is anything I can change in it to make this work.

if(!empty($_POST['OUSdrop'])){
    foreach($_POST['OUSdrop'] as $check){
        echo $check;
    }
}


<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="UKSen">
    <input type="checkbox" id="UKSen" name="OUSdrop[]" class="mdl-checkbox__input">
    <span class="mdl-checkbox__label" value="UK">United Kingdom</span>
</label>

why don't change it as

<input type="checkbox" id="UKSen" name="OUSdrop[UK]" class="mdl-
checkbox__input">

so that you know which one you want to set?

And also change the loop

foreach($_POST['OUSdrop'] as $check => $value){
        echo $check.':'.$value;
}

Try this:

if(!empty($_POST['OUSdrop'])){

    foreach($_POST['OUSdrop'] as $check => $value){
        echo $check;

    }
}

HTML CODE

<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="UKSen">
        <input type="checkbox" id="UKSen" name="OUSdrop[HERE]" class="mdl-checkbox__input">
        <span class="mdl-checkbox__label" value="UK">United Kingdom</span>
</label>

$check will contain the key ans $value the value.

You have set the value in span tag which should be in input

When value is not defined most browsers will default to value="on" which means that it's 'on' (checked)

if (! empty($_POST['OUSdrop'])) {
    foreach($_POST['OUSdrop'] as $check) {
        echo $check;
    }
}


<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="UKSen">
    <input type="checkbox" 
           id="UKSen" 
           name="OUSdrop[]" 
           class="mdl-checkbox__input"  
           value="UK">
    <span class="mdl-checkbox__label">United Kingdom</span>
</label>