答案 1
PHP使用方括号语法将表单输入转换为数组,因此当您使用时,当您执行此操作时,您将获得一个数组:name="education[]"
$educationValues = $_POST['education']; // Returns an array
print_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>
答案 2
如果有复选框,则可以传递已检查值的数组。
<input type="checkbox" name="fruits[]" value="orange"/>
<input type="checkbox" name="fruits[]" value="apple"/>
<input type="checkbox" name="fruits[]" value="banana"/>
还有多个选择下拉列表
<select name="fruits[]" multiple>
<option>apple</option>
<option>orange</option>
<option>pear</option>
</select>
推荐
-
相当于Java中PHP的crypt函数 我正在将我的PHP代码迁移到Google App Engine - Java。因此,我需要一个相当于Java中PHP的crypt函数,因为我已将使用crypt的注册用户的所有密码存储在我的数据库中。 编辑1:这是我用于加密密码的php
-
需要有关如何从接受语言请求标头获取首选语言的示例 我需要一个代码示例或库来解析标头并返回我的首选语言。 指出: “接受语言请求标头”字段类似于“接受”,但限制首选作为请求响应的自然语言集。语言标记在第 3.10 节中定义。
-
无法在 Java 和 PHP 之间交换使用 AES-256 加密的数据 我的问题是:我在Java中加密的东西,我可以在Java中完全解密,但PHP不能解密。我用加密的内容可以使用 解密,但不能在 Java 中解密。 我想从Java应用程序发送和接收加密数据到PHP页面,所以我
-
-
Quercus是Java环境中PHP的可行替代品吗? 对于任何偶然发现这个问题的人,他们不知道是什么 - 它是用Java完成的PHP的实现。 对于我目前正在从事的项目,我们通过cgi在servlet上提供php页面(我知道它很笨拙,但这是支持遗留代码的要求
标签