title: How to handle checkbox values in a query string?
body: <p>I have a query string that has a bunch of form field values in it. One of the fields is a checkbox and it creates duplicate parameters, for example: </p>
  
  <blockquote>
    <p>?employee_selection_needs=cat&amp;employee_selection_needs=dog&amp;employee_selection_needs=pig</p>
  </blockquote>
  
  <p>I need to place all of these checkbox values into one variable to be submitted to the HubSpot API. How can I accomplish that? I've tried it with a <code>foreach</code> loop but that does not seem to work.</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>$firstname = $_POST["firstname"];
  $lastname = $_POST["lastname"];
  $email = $_POST["email"];
  $organization_name = $_POST["organization_name"];
  $phone = $_POST["phone"];
  $best_describes_org = $_POST["best_describes_org"];
  $organizations_safety = $_POST["organizations_safety"];
  $confident_interview_process = $_POST["confident_interview_process"];
  $needs_around_leadership = $_POST["needs_around_leadership"];
  $used_employee_assessments = $_POST["used_employee_assessments"];
  $hire_annually = $_POST["hire_annually"];
  
  foreach($_POST['employee_selection_needs'] as $needs) {
      $employee_selection_needs .= $needs;
  }
  
  
  
  //Need to populate these variable with values from the form.
  $str_post = "firstname=" . urlencode($firstname) 
      . "&amp;lastname=" . urlencode($lastname) 
      . "&amp;email=" . urlencode($email) 
      . "&amp;phone=" . urlencode($phonenumber) 
      . "&amp;organization_name=" . urlencode($organization_name) 
      . "&amp;best_describes_org=" . urlencode($best_describes_org) 
      . "&amp;employee_selection_needs=" . urlencode($employee_selection_needs) 
      . "&amp;organizations_safety=" . urlencode($organizations_safety) 
      . "&amp;confident_interview_process=" . urlencode($confident_interview_process) 
      . "&amp;needs_around_leadership=" . urlencode($needs_around_leadership) 
      . "&amp;used_employee_assessments=" . urlencode($used_employee_assessments) 
      . "&amp;hire_annually=" . urlencode($hire_annually) 
      . "&amp;hs_context=" . urlencode($hs_context_json); //Leave this one be
  </code></pre>