PHP - 从选择列表中填充数组

时间:2014-04-09 22:32:49

标签: php forms

我有一个带选项的选择列表。我如何使用该列表中的所有选项填充数组?

//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.
?>

1 个答案:

答案 0 :(得分:0)

您需要在列表名称中添加方括号:

<select name="selectitem[]" multiple="multiple">