你可以做到这一点,它实际上是有些直观的(假设我理解你的问题)
对于HTML,你有你的名字领域主要有两个数组。数字应该随着您复制字段而改变。以下将生成两个不同的“记录”,作为“person”数组中的数组。从上面的
<form action="" method="POST">
<input type="text" name="person[1]['first']"/>
<input type="text" name="person[1]['last']"/>
<input type="text" name="person[1]['email']"/>
<input type="text" name="person[2]['first']"/>
<input type="text" name="person[2]['last']"/>
<input type="text" name="person[2]['email']"/>
<input type="submit">
</form>
而PHP
<?
foreach ($_POST as $name => $value) {
print_r($value);
// $value is an individual "record." You could then insert, for example, $value['first'], $value['last'], etc. within this loop.
}
?>
示例输出:
阵列([1] =>数组([ '第一'] =>约翰[ '最后' ] => Matthews ['email'] => [email protected])[2] =>阵列(['first'] => Carol ['last'] => Martinex ['email'] => email @ email .com))
希望这是有道理的,我可以尝试澄清,如果需要。
谢谢您的回复。我会试试看看它是否有效,如果我需要进一步澄清,我一定会告诉你。我非常感谢你的帮助。 –