Why variable_get() returns all values of checkboxes list, even if checkbox is not selected? I have checkboxes list in system settings form:

$form['mymodule_menu_perm_menus'] = array(
    '#type' =&gt; 'checkboxes',
    '#title' =&gt; t('Menus'),
    '#options' =&gt; menu_get_menus(TRUE),
    '#default_value' =&gt; variable_get('mymodule_menu_perm_menus', array()),        
);

return system_settings_form($form);


I submit this form with two checkboxes selected.

But on other page variable_get('mymodule_menu_perm_menus') return all values :/

Clearing cache doesn't help
Because Drupal doesn't actually filter out empty checkboxes values, it sets them to zero. I think this is so you get an accurate representation of what options were available when the form was submitted, and what was actually chosen by the user.

It's easy to get the filtered array though, using array_filter():

$values = array_filter(variable_get('mymodule_menu_perm_menus', array()));