0

I have a select list with options. How would I go about populating an array with all of the options in that list?

//form
<form method="post" action="popArray.php">
  <select name="selectitem" multiple="multiple">
    <option value="United States">United States</option>
    <option value="Russia">Russia</option>
    <option value="North Korea">North Korea</option>
  </select>
  <input type="submit" value="List">
</form>
//popArray.php
<?php
$areas = array();
//throw all the options into that array.
?>
  • 2
    Do you have control over the form? Why not just create an array of values first, then generate a select for that? – Shane Apr 09 '14 at 22:36
  • Possible dup of http://stackoverflow.com/questions/15190464/how-do-i-post-all-options-in-a-select-list – John Apr 09 '14 at 22:50

1 Answers1

0

You need to add square brackets to list's name:

<select name="selectitem[]" multiple="multiple">
Rafał Walczak
  • 543
  • 5
  • 11