Suppose we have an html page with the following code:
Copy the code The code is as follows:
Pay attention to the name attribute of the input above. The content of each attribute is the same, and they are all test[]. The reason for adding [] is to transfer the content of test into an array. The code content of
checkTest.php is as follows:
Copy code The code is as follows:
echo implode(",",$_POST['test']);
?>
When we output the content, we only need to pay attention to using the implode function to convert the array content into a string. .
Note: This function can be used in situations such as deleting multiple records. For example, Delete from tbl where ID in (implode(",",$_POST['test'])).
Example code:
Copy code The code is as follows:
< ;title>Untitled document
If the html checkbox is to be sent to the php script for processing in the form of a data group, it must be in the form of checkbox[ ]This form
//Determine whether to click submit
if( $_POST)
{
$array = $_POST[' checkbox'];
print_r($array);
}
/*
Result:
Array
(
[0] => 1
[1 ] => 2
[2] => www.jb51.net
[3] => jb51.net
)
Many simple things feel complicated before you do them, but when you do them It's easy, just like this checkbox code.
*/
?>
http://www.bkjia.com/PHPjc/322288.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322288.htmlTechArticleSuppose we have an html page with the following code: Copy the code and the code is as follows: FORM method="post" action=" checkTest.php" INPUT name="test[]" type="checkbox" value="1" / INPUT type="check...