<form method="post" action="arrayformdata.php">
<label>Tags</label>
<input type="text" name="tags[]"/>
<input type="text" name="tags[]"/>
<input type="text" name="tags[]"/>
<input type="text" name="tags[]"/>
<input type="text" name="tags[]"/>
<input type="submit" value="submit">
</form>
</html>
这样就可以在php中通过$_POST['tags']得到所有name为tags[]的值并合并到一个数组内。
不明白它的原理是怎样的
提交的时候你可以看到请求的form信息中是
当php收到这个信息后,会将变量以关联数组形式传入当前脚本。既然是关联数组,那么就会存在key,而上面tags[]是同一组key。php在处理的时候就会把他们放到一个数组里。