Home > Article > Backend Development > How to get the values of multiple input elements with the same name in a form in php
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!