The problem may sound a bit around.
That's my form page. The individual number of tables is variable, because there is a button to increase the form, the user can press this button to increase the number of the table, and the name of the form I was to make it a "prefix + increment number" form, such as "Array_1", "array_2", but the exact number is uncertain, Because it depends on how many forms the user has added, I'm now going to put all the values of all the forms with array_ prefixes into an array, how do I do that? The key problem is that the number of non-forms is undefined.
Novice study, do not know to describe the problem clearly no, first thanked
Reply to discussion (solution)
Whether to increase the form or increase the form element
Do you have n forms in a page?
If there are multiple forms, I'm currently using jquery to dynamically get all the form values and then pass them to the background
var postdata= ""; $.each ($ ("from"), function (i, n) { PostData + = $ (n). serialize ();}); /via AJAX to the backstage.
This post was last edited by xuzuning on 2013-12-28 16:32:56
There are multiple forms, only multiple form variables
foreach (Preg_grep ('/array_/', Array_keys ($_post)) as $k) { res[$k] = $_post[$k];}
$res is the result you need.
In fact you are not named Array_ numbers, but named array[] don't need that much trouble.
There are multiple forms, only multiple form variables
foreach (Preg_grep ('/array_/', Array_keys ($_post)) as $k) { res[$k] = $_post[$k];}
$res is the result you need.
In fact you are not named Array_ numbers, but named array[] don't need that much trouble.
Thanks, if the name is array[] how to do?
Whether to increase the form or increase the form element
Do you have n forms in a page?
If there are multiple forms, I'm currently using jquery to dynamically get all the form values and then pass them to the background
var postdata= ""; $.each ($ ("from"), function (i, n) { PostData + = $ (n). serialize ();}); /via AJAX to the backstage.
Thanks, I have a problem with multiple form elements, that is, multiple input tags, not multiple forms
Multiple form input tags, which can be distinguished by the name attribute.
Define the name of the same group of elements as an array, as follows:
.........
PHP Reception is
Print_r ($_post[' array ');
Define the name of the same group of elements as an array, as follows:
.........
PHP Reception is
Print_r ($_post[' array ');
Originally can this, so convenient, teachable, thanks!
Print_r ($_post[' array ' [' A1 ']);
Print_r ($_post[' array ' [' A2 ']);
This allows you to differentiate the input value
There are multiple forms, only multiple form variables
foreach (Preg_grep ('/array_/', Array_keys ($_post)) as $k) { res[$k] = $_post[$k];}
$res is the result you need.
In fact you are not named Array_ numbers, but named array[] don't need that much trouble.
jordan102 Moderator greatly answered my question, or thank you very much