Home > Backend Development > PHP Tutorial > php how to get array passed from html form

php how to get array passed from html form

墨辰丷
Release: 2023-03-31 18:18:01
Original
2569 people have browsed it

This article mainly introduces the method of PHP to obtain the array passed from the HTML form. The example analyzes the skills of PHP to operate the form elements. It is of great practical value. Friends who need it can refer to it.

The examples in this article describe PHP get method of passing array from html form. Share it with everyone for your reference. The details are as follows:

Set the name of each element of the form to the same array object. You can also pass the form value in the form of an array.

The html page is as follows:

<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>
Copy after login

arrayformdata The .php page is as follows:

<?php
$postedtags = $_POST[&#39;tags&#39;];
foreach ($postedtags as $tag){
  echo "<br />$tag";
}
?>
Copy after login

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

PHP encryption and decryption functions generate encryption and decryption strings

The database in PHP implements more secure permanent login and recording Live my function

PHP is based on Ajax to realize non-refresh login and exit

The above is the detailed content of php how to get array passed from html form. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template