How PHP Gets the value of the corresponding form by matching the partial string of the table sole name

Source: Internet
Author: User
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
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.