To get the values of multiple checkboxes in PHP, be sure to add [] to the value of the check box's Name property

Source: Internet
Author: User
To get more than one check box value in PHP, be sure to add [] to the check box's Name property value
I found the PHP program, in order to get the value of the check box, usually give the check box's Name property plus [], for example:

New User Registration




Can not add, in other ways to replace, because I want to convert the ASP program to PHP program, I hope the HTML file does not change the best.
Also, that is, add this hobby[], the obtained will be the number of groups, not add is not, this and ASP is also different oh, ASP for more than one name attribute value of the same element, gets the always array.

Share to:


------Solution--------------------
There's no way to change that.
------Solution--------------------
If you want to not change the HTML structure and want to get an array of multi-box, then the landlord can use JS to get the value of multi-box and composite JS array, and then pass the value to PHP.

------Solution--------------------
This is a convention of PHP, unless you modify the kernel, you cannot change

But you can also handle the submitted data yourself, hoping you have the ability
For forms


After submission with
Echo UrlDecode (file_get_contents (' php://input '));
You will get a string shaped like this: name=&sex=1&hobby= Music &hobby= Tour
What do we do next? That's your own business.
  • 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.