title: Setting multiple default selected values in multi select dropdown
body: <pre><code>// Get Series List
      $this-&gt;load-&gt;model('Series_model');
      $serieslist = $this-&gt;Series_model-&gt;gettypelist($userid, 'e');
  
      $series_item_id = 0;
  
      $this-&gt;db-&gt;select('series_id');
      $this-&gt;db-&gt;where('type_id', 13);
      $this-&gt;db-&gt;where('series_type', 'e');
      $series_item_query = $this-&gt;db-&gt;get('series_items');
  
      if ($series_item_query-&gt;num_rows() &gt; 0) {
          $series_item_id = $series_item_query-&gt;result();
      }
      //print_r($series_item_id);
  
      $data['serieslist'] = '&lt;select name="series_id[]" class="type input_select" multiple="multiple"&gt;';
      $data['serieslist'] .= '&lt;option value=""&gt;None&lt;/option&gt;';
      foreach ($serieslist as $list) {
          $data['serieslist'] .= '&lt;option value="' . $list-&gt;id . '" ' . ($series_item_id[0]-&gt;series_id === $list-&gt;id ? 'selected="selected"' : '') . '&gt;' . $list-&gt;title . '&lt;/option&gt;';
      }
      $data['serieslist'] .= '&lt;/select&gt;';
  </code></pre>
  
  <p>Above is the code I am working with.  What I would like to be able to do is to set multiple selected="selected"'s for multiple values of a select dropdown menu.  So for example:</p>
  
  <pre><code>&lt;select name="series_id[]" class="type input_select" multiple="multiple"&gt;
      &lt;option value=""&gt;None&lt;/option&gt;
      &lt;option value="4"&gt;Event Series: Test 1&lt;/option&gt;
      &lt;option value="5"&gt;Event Series: Test 2&lt;/option&gt;
      &lt;option value="16"&gt;Event Series: Test 3&lt;/option&gt;
      &lt;option value="17"&gt;Event Series: Test 4&lt;/option&gt;
      &lt;option value="18"&gt;Event Series: Test 5&lt;/option&gt;
      &lt;option value="19"&gt;Event Series: Test 6&lt;/option&gt;
      &lt;option value="20"&gt;Event Series: Test 7&lt;/option&gt;
      &lt;option value="21"&gt;Event Series: Test 8&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>I would like option values of 4 16 and 19 to be selected="selected", but in my code above it is only selecting 4 and then stopping.  what am I missing?  If you need further information please let me know.</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT:</p>
  
  <p>Result of print_r:</p>
  
  <pre><code>Array ( [0] =&gt; stdClass Object ( [series_id] =&gt; 4 ) [1] =&gt; stdClass Object ( [series_id] =&gt; 16 ) [2] =&gt; stdClass Object ( [series_id] =&gt; 19 ) )
  </code></pre>
  
  <p>Updated code:</p>
  
  <pre><code>foreach ($serieslist as $list) {
          $data['serieslist'] .= '&lt;option value="' . $list-&gt;id . '" ' . (in_array($list-&gt;id, $series_item_id, TRUE) ? 'selected="selected"' : '') . '&gt;' . $list-&gt;title . '&lt;/option&gt;';
      }
  </code></pre>
  
  <p>Above updated code does not work.</p>