Home  >  Article  >  Backend Development  >  How to get the values ​​of multiple input elements with the same name in a form in php

How to get the values ​​of multiple input elements with the same name in a form in php

怪我咯
怪我咯Original
2017-07-11 14:19:422197browse

Sometimes the front page needs to allow dynamic addition/deletion of multiple values ​​of a certain attribute, such as adding books to the bookshelf, and it must be possible to dynamically add or delete books.

There will be multiple input elements in the form of the front page, as follows:

<form action="a.php"> 
<input type="text" name="books[]"/> 
<input type="text" name="books[]"/> 
<input type="text" name="books[]"/> 
<input type="submit" name="submit" /> 
</form>

When the a.php page receives the form data, you can use $books = $_REQUEST['books'] ;Get the array of all book titles.

The above is the detailed content of How to get the values ​​of multiple input elements with the same name in a form in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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