title: How to get all the values from a HTML select element in php?
body: <p>I have a HTML form with two select elements(listboxes) and two buttons to move the data from one listbox to another(using JavaScript):</p>
  
  <pre><code> &lt;form action="page.php" method="post"&gt;
          &lt;select name="select1" multiple="yes"&gt;
              &lt;option value="1"&gt;Left1&lt;/option&gt;
              &lt;option value="2"&gt;Left2&lt;/option&gt;
              &lt;option value="3"&gt;Left3&lt;/option&gt;
          &lt;/select&gt;
          &lt;input type="button" value="--&amp;gt;" onclick="moveOptions(this.form.select1, this.form.select2);" /&gt;&lt;br /&gt;
          &lt;input type="button" value="&amp;lt;--" onclick="moveOptions(this.form.select2, this.form.select1);" /&gt;
          &lt;select name="select2" multiple="yes"&gt;
              &lt;option value="4"&gt;Right1&lt;/option&gt;
              &lt;option value="5"&gt;Right2&lt;/option&gt;
          &lt;/select&gt;
          &lt;input type="submit" name="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When I hit the Submit button I want to get <strong>all the values</strong> stored in the listboxes. </p>
  
  <pre><code>foreach ($_POST['select1'] as $value)
      {
          //save data to database
      }
  </code></pre>
  
  <p>This just gets one selected value(if there was one).</p>
  
  <p>I managed to get multiple values (if they are selected) by putting a <code>[]</code> after the name of the <code>select</code>.</p>
  
  <pre><code>&lt;select name="select1[]" multiple="yes"&gt;
  </code></pre>
  
  <p>But this still doesn't gets the unselected values, and this way the data moving JavaScript function doesn't works either.</p>