PHP使用方括号语法将表单输入转换为数组,因此使用
name="education[]"时将获得一个数组:
$educationValues = $_POST['education']; // Returns an arrayprint_r($educationValues); // Shows you all the values in the array
因此,例如:
<p><label>Please enter your most recent education<br> <input type="text" name="education[]"></p><p><label>Please enter any previous education<br> <input type="text" name="education[]"></p><p><label>Please enter any previous education<br> <input type="text" name="education[]"></p>
将为您提供
$_POST['education']数组内所有输入的值。
在Javascript中,通过id获取元素更有效。
document.getElementById("education1");ID不必与名称匹配:
<p><label>Please enter your most recent education<br> <input type="text" name="education[]" id="education1"></p>


![HTML元素数组,名称=“ something []”或名称=“ something”? HTML元素数组,名称=“ something []”或名称=“ something”?](http://www.mshxw.com/aiimages/31/382757.png)
