Php: how to obtain the array passed from an html form
This article mainly introduces how to obtain the array passed from html forms by php. The example analyzes the php operation form element technique, which is very useful. For more information, see
The example in this article describes how php retrieves an array transmitted from an html form. Share it with you for your reference. The details are as follows:
You can set the name of each element in the form to the same Array object and pass the form value in an array.
The html page is as follows:
?
| 1 2 3 4 5 6 7 8 9 10 |
<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> |
The arrayformdata. php page is as follows:
?
| 1 2 3 4 5 6 |
<? Php $ Postedtags = $ _ POST ['tags']; Foreach ($ postedtags as $ tag ){ Echo "<br/> $ tag "; } ?> |
I hope this article will help you with php programming.