Help: How does PHP get the value of the corresponding form by matching the partial string of the table sole name?
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
Share to: more
------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 ();
});
To the backstage through Ajax.
------Solution--------------------
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.
------Solution--------------------
Define the name of the same group of elements as an array, as follows:
.........
PHP Reception is
Print_r ($_post[' array ');
------Solution--------------------
Print_r ($_post[' array ' [' A1 ']);
Print_r ($_post[' array ' [' A2 ']);
This allows you to differentiate the input value