title: How to pass multiple checkbox values to php
body: <p>Currently i have a HTML form that collects some metadata about some files, and each user as to fill some fields. I want to register some keywords about the data. I could ask them to write the keywords by hand on a normal text box, but i would prefer to have a list of checkboxes of about 10/15 values. </p>
  
  <p>Then i need to pass only the checked values to a PHP file, using <code>$_POST</code>. My problem is that i assign a variable to those values, and then i call that variable in a DOM event. I´m generating a XML file, and currently i have the HTML ready to register these keywords in text input. I understand how to create the checkboxes, and pass them as an array to PHP., by reading other questions here. But i can´t understand how to pass this array to a <code>$dom-&gt;createElement</code> situation, and preferably separated by commas.</p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>//Pull data from HTML form
  $keywordsString = $_POST['keywords'];
  
  // Creates xml document
  $dom = new DOMDocument();
      $dom-&gt;encoding = 'utf-8';
      $dom-&gt;xmlVersion = '1.0';
      $dom-&gt;formatOutput = true;
  
  $xmlFileName = 'example_example.xml';
  
  // Adds metadata to xml
  $metadata = $dom-&gt;createElement('MD_Metadata');
  
      $idInfo = $dom-&gt;createElement('identificationInfo');
          $descriptiveKeywords = $dom-&gt;createElement('descriptiveKeywords');
                  $CharacterString = $dom-&gt;createElement('CharacterString', $keywordsString);
                  $descriptiveKeywords-&gt;appendChild($CharacterString);
              $idInfo-&gt;appendChild($descriptiveKeywords);
      $metadata-&gt;appendChild($idInfo);
  
  $dom-&gt;appendChild($metadata);
  
  $dom-&gt;save($xmlFileName);
  
  </code></pre>
  
  <p>I can´t figure out how to pass checkbox values to that <code>$keywordsString</code> , but separated by commas. The rest i can understand and write, using the other questions about this kind of issue. </p>
  
  <p>Thanks in advance for all help provided.</p>