To obtain the values of multiple check boxes in PHP, must the name attribute value of the check box be added []?

Source: Internet
Author: User
To obtain the values of multiple check boxes in PHP, do you need to add [] to the name attribute value of the check box? I found that the value of the check box is obtained in the PHP program, generally, [] is added to the name attribute of the check box, for example, & lt; html & gt; & lt; body & gt; & lt; h1 & nbsp; align = "center" & gt; when a new user obtains the values of multiple check boxes in PHP, must the name attribute value of the check box be added []?
I found that in PHP programs, to obtain the value of the check box, we usually add [] to the name attribute of the check box, for example:

New user registration


I can't help but use other methods to replace it, because I want to convert ASP Programs to PHP programs. I hope it is best not to change HTML files.
Also, that is to say, with this Hoby [] added, the obtained result will be an array. if it is not added, it is not. this is also different from ASP, ASP always obtains an array for elements with the same attribute values. Share To: new user registration
------ Solution --------------------
This cannot be changed.
------ Solution --------------------
If you want to get the array of multiple selection boxes without changing the HTML structure, you can use JS to get the value of multiple selection boxes and synthesize the JS array, and then pass the value to PHP.

------ Solution --------------------
This is a php convention. it cannot be changed unless the kernel is modified.

However, you can also process the submitted data on your own.
For forms


Submit and use
Echo urldecode (file_get_contents ('php: // input '));
You will get a string like this: name = & Sex = 1 & holobby = Music & holobby = travel
As for what to do next? That's your own thing.

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.