title: Get only selected value from the dropdown and remove unselected value from the dropdown
body: <p>I have two multiple dropdown in which one dropdown i have all the fields with all the values and in second drop down i have shown the selected value but with this all the other values are also coming which i have not selected ,i want to show only those three values which i have selected at the time of add record and values are saved comma separately in db(1,2,3).
  Below is my php code which shows selected value as well as all the other value also.So i want to remove that values from the second dropdown which i have not added.Where $state is a array which shows all the list of with there id and name. </p>
  
  <pre><code>  &lt;div class="form-group end"&gt;
                  &lt;select id="second" multiple="true" name="states[]" id="states" &gt;
                  &lt;?php
                      foreach($states as $key =&gt; $val){
                          $value = $val-&gt;id;
                          $name = $val-&gt;name;
                          $selected = 1,2,3;
                          $selected_values = explode(",",$selected);
                          echo "&lt;option value='$value'".((in_array($value,$selected_values)) ? " selected='selected'":"")."&gt;$name&lt;/option&gt;";
                       }
                       //var_dump($name);die;
                      ?&gt;
                 &lt;/select&gt;
  </code></pre>
  
  <p>My multiple drop down is like this 
  <a href="http://jsfiddle.net/h8zuc/" rel="nofollow noreferrer">http://jsfiddle.net/h8zuc/</a></p>