title: I can't get multiple selected values of select box in php
body: <p>So, I have an HTML/PHP form that has a select list box from which you can select multiple values because its multiple properties are set to multiple. Consider the form method is 'POST'. But the list box is saving only one value when I click on SUBMIT (to be specific the last value chosen). I don't know why.</p>
  
  <p>This is part of my code:</p>
  
  <pre class="lang-html prettyprint-override"><code>
      &lt;?php
      if(isset($_POST['submitSave'])) {
      // Disable errors due to empty xml files
          error_reporting(E_ALL &amp; ~E_WARNING);
  
          $domDoc = new DOMDocument('1.0', 'UTF-8');
          $domDoc-&gt;preserveWhiteSpace = false;
          $domDoc-&gt;formatOutput = true;
          $domDoc-&gt;encoding = 'UTF-8';
          $domDoc-&gt;load('./data/expression.xml');
          $xpath = new DOMXpath($domDoc);
  
  
          if($domDoc-&gt;getElementsByTagName('expression')-&gt;length&gt;0){
              // If we already have expression tag defined
              $expression = $domDoc-&gt;getElementsByTagName('expression')[0];
          }else{
              // If we don't have any expression tag, i.e. file is empty
              $expression = $domDoc-&gt;createElement('expression');
          }
  
      $vocabulario = $domDoc-&gt;createElement('vocabulario');
      $vocabulario-&gt;setAttribute('word', $_POST['word']);
      $classe = $domDoc-&gt;createElement('classe', $_POST['classe']);
  
      $domDoc-&gt;appendChild($expression);
      $expression-&gt;appendChild($vocabulario);
      $vocabulario-&gt;appendChild($classe);
  
      file_put_contents('./data/expression.xml', $domDoc-&gt;saveXML());
      header('location:index.php');
  
  }
  ?&gt;
  
  &lt;form method="post"&gt;
  &lt;div class="col-75"&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"&gt;&lt;/script&gt;
    &lt;link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.css" rel="stylesheet" /&gt;
    &lt;select name="classe[]" multiple="multiple"&gt;
      &lt;option value="| adjective |"&gt;adjective&lt;/option&gt;
      &lt;option value="| adverb |"&gt;adverb&lt;/option&gt;
      &lt;option value="| noun |"&gt;noun&lt;/option&gt;
      &lt;option value="| verb |"&gt;verb&lt;/option&gt;
    &lt;/select&gt;
    &lt;script type="text/javascript"&gt;
      var s2 = $("#classe").select2({
        placeholder: "Select",
        tags: true
      });
    &lt;/script&gt;
  &lt;/div&gt;
  
  &lt;div class="row"&gt;
    &lt;td&gt;&lt;input type="submit" value="Save" name="submitSave"&gt;&lt;/td&gt;
  &lt;/div&gt;
  </code></pre>