I encountered a problem today. I had to save a lot of form information. After worrying about it for a long time, I finally found a pretty good way to use an array. Submit the data in the form to the background for saving.
In fact, it is very simple to implement, that is, there must be certain standards when naming the information to be submitted in the form. Let us first compare the differences between the following two methods:
The first, common way, each value to be submitted has a name
<form id="form1" action="./index.php" method="get"> <div class="form-control"> <input type="text" name="name1" /> <input type="text" name="num1" /> <input type="text" name="img1" /> </div> <br> <div class="form-control"> <input type="text" name="name2" /> <input type="text" name="num2" /> <input type="text" name="img2" /> </div> <br> <div class="form-control"> <input type="text" name="name3" /> <input type="text" name="num3" /> <input type="text" name="img3" /> </div> ...... <input type="submit" value="Submit" /> </form>
The service (index.php) is as simple as two sentences
<?php echo "<pre class="brush:php;toolbar:false">"; print_r($_GET);
Fill in the following information on the rendered webpage and click submit
If you look carefully, you will find that the name of the data to be submitted has changed. It may not be obvious here. When you click submit, you will find that the values passed to the backend are much neater. Take a look at the screenshot below
The query string parsed through the browser plug-in is like this
First look at the data passed by the browser
The copyright of this article belongs to the author iforever (luluyrt@163.com). Any form of reprinting is prohibited without the author's consent. After reprinting the article, the author and the original text link must be given in an obvious position on the article page, otherwise we will reserve the right to pursue it. Legal liability rights.