This is a very basic HTML form submission question, but it is a very practical technique
My business scenario is like this:
A form that can dynamically create input, as shown below
This means that the name of the input cannot be fixed, otherwise it will definitely be overwritten.
The first one is the traditional ordinary submission method, giving each input to be submitted a unique name.
The format that the browser submits and captures is like this
What the server gets and prints is like this, which is very unfriendly to back-end data processing.

The second method is to submit the form using an array.
The browser and back-end printing are respectively

After careful observation, you will find that the submitted name value has changed and become the same? Array?
After submitting it to the backend, I found that the data was much neater than before.
But what should be noted here is that you do not need to use quotation marks in the submitted array key, otherwise the quotation marks will become part of the key.
Of course, you may encounter such a problem in practice. The number of groups to be submitted (like 1, 2, and 3 above) is uncertain and can be added at will on the front end. How do you use an array to submit these contents at this time?
Here is the actual solution in my business
In this case, the keys of the two-dimensional array do not need to be maintained by ourselves, and the browser will automatically generate them for us.
The data received by the backend becomes like this, which becomes very easy to process.
This method is suitable for submitting a bunch of related data pairs of an uncertain number.
Finished spreading flowers! ~