How PHP gets the values of all the check boxes in the form _php tips

Source: Internet
Author: User

In general, PHP always gets the value of only the last check box, so how do you get the value of all the check boxes?

The solution is as follows:

Part of the code for the form form is as follows:

<input type= "checkbox" Name= "frm_tag[]" value= "1" >1 <input "
checkbox" type= "Name=" "frm_tag[" 2 " >2
<input type= "checkbox" Name= "frm_tag[]" value= "3" >3 <input "
checkbox" type= "Name=" Value= "4" >4
<input type= "checkbox" Name= "frm_tag[]" value= "5" >5

The code that the PHP process post passes over the data is as follows:

$str _tag = "";
$frm _tag = $_post[' Frm_tag '];
For ($i =0 $i <count ($frm _tag), $i + +) {
  echo $frm _tag[$i]. " <br> ";
  if ($i ==0)
   $str _tag = $frm _tag[$i];
  else
   $str _tag = $str _tag. ",". $frm _tag[$i];
echo $str _tag;
}

I believe that this article on the in-depth master of the PHP program design has a certain reference value.

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.