将表单的各个元素的name都设置成同一个数组对象既可以以数组的方式传递表单值
<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> To receive the array in a php script, we use the $_POST as <pre lang="php"> <?php $postedtags = $_POST['tags']; foreach ($postedtags as $tag){ echo "<br />$tag"; } ?>