title: Why aren't options saving to database?
body: <p>With this code, the selected options are saved to the database:</p>
  
  <pre><code>&lt;select name="menu-item-visibility[&lt;?php echo $item_id; ?&gt;][]" id="edit-menu-item-visibility-&lt;?php echo $item_id; ?&gt;" class="chzn-select" multiple="true"
      &lt;option value="US" &lt;?php $val = get_post_meta( $item_id, 'locations', true ); if ( is_array( $val ) ) { if ( in_array( "US", $val ) ) { echo "selected='selected'"; } else { echo ""; } } ?&gt; &gt;United States&lt;/option&gt;
      &lt;option value="TH" &lt;?php $val = get_post_meta( $item_id, 'locations', true ); if ( is_array( $val ) ) { if ( in_array( "TH", $val ) ) { echo "selected='selected'"; } else { echo ""; } } ?&gt; &gt;Thailand&lt;/option&gt;
      ...
  &lt;/select&gt;
  </code></pre>
  
  <p>With this code, they are not:</p>
  
  <pre><code>&lt;select name="menu-item-visibility[&lt;?php echo $item_id; ?&gt;][]" id="edit-menu-item-visibility-&lt;?php echo $item_id; ?&gt;" class="chzn-select" multiple="true" data-placeholder="Select Countries"&gt;
  &lt;?php
  $countries = array('US' =&gt; 'United States', "TH" =&gt; "Thailand");
  $vals = get_post_meta( $item_id, 'locations', true );
  foreach($countries as $key =&gt; $value) { 
  ?&gt;
      &lt;option value="&lt;?php echo $key;?&gt;"
      &lt;?php echo (is_array( $vals ) &amp;&amp; in_array( $key, $vals ) ) ? "selected='selected'" : ''; ?&gt; &gt;
      &lt;?php echo $value;?&gt;
      &lt;/option&gt;
  &lt;?php
  }
  ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Why not?</p>
  
  <p>This is how options are sent to the database:</p>
  
  <pre><code>/* Put locations in the database. */
  function csmi_update_locations( $menu_id, $menu_item_db_id, $args ) {
      $meta_value = get_post_meta( $menu_item_db_id, 'locations', true );
      if ( isset( $_POST[ 'menu-item-visibility' ][ $menu_item_db_id ] ) ) { 
          $new_meta_value = $_POST[ 'menu-item-visibility' ][ $menu_item_db_id ]; 
          if ( !isset( $new_meta_value ) ) {
              delete_post_meta( $menu_item_db_id, 'locations', $meta_value );
          }
          elseif ( $meta_value !== $new_meta_value ) {
              update_post_meta( $menu_item_db_id, 'locations', $new_meta_value );
          }
      }
  }
  </code></pre>
  
  <p>Here's the HTML in view source as requested. </p>
  
  <pre><code>&lt;p class="field-visibility description description-wide"&gt;
  ...
      &lt;select name="menu-item-visibility[4][]" id="edit-menu-item-visibility-4" class="chzn-select" multiple="true" data-placeholder="Select Countries"&gt;
          &lt;option value="US"  &gt; United States &lt;/option&gt;
          &lt;option value="TH"  &gt; Thailand &lt;/option&gt;
      &lt;/select&gt;
  &lt;/p&gt;
  </code></pre>