title: PHP How to send multiple values within the same name
body: <p>So here is my current code. This code has 6 inputs within the form. The names on the last 3 inputs are. firstanswer, secondanswer and thirdanswer. </p>
  
  <pre><code>&lt;form action="addsurvey.php" method="post"&gt;
    &lt;input type="text" name="surveyname"&gt;
    &lt;input type="text" name="question" placeholder="First Question"&gt;
    &lt;br&gt;
    &lt;input type="text" name="firstanswer" value=""&gt;
    &lt;input type="text" name="secondanswer" value=""&gt;
    &lt;input type="text" name="thirdanswer" value=""&gt;
    &lt;br&gt;
    &lt;input type="submit" name="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When they get submitted the php file I set the variables like this.</p>
  
  <pre><code>$firstanswer = $_POST['firstanswer'];
  $secondanswer = $_POST['secondanswer'];
  $thirdanswer = $_POST['thirdanswer'];
  
  $answers = array();
  
  array_push($answers, $firstanswer);
  array_push($answers, $secondanswer);
  array_push($answers, $thirdanswer);
  
  </code></pre>
  
  <p>This code would make sense if I knew every single user was going to only enter in three possible answers for their form. But I do not know for sure. Is there a way I can use the same name on the last three inputs and send them into some sort of array for example.</p>
  
  <pre><code>&lt;form action="addsurvey.php" method="post"&gt;
    &lt;input type="text" name="surveyname"&gt;
    &lt;input type="text" name="question" placeholder="First Question"&gt;
    &lt;br&gt;
    &lt;input type="text" name="answer" value=""&gt;
    &lt;input type="text" name="answer" value=""&gt;
    &lt;input type="text" name="answer" value=""&gt;
    &lt;br&gt;
    &lt;input type="submit" name="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Then in the php it would be pushed onto an array.
  To recap. I want to be able to use the same name for the inputs to then add into an array.</p>