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, each The attribute contents are all the same, and they are all test[]. The reason for adding [] is to transfer the test content into an array. The code content of
checkTest.php is as follows:
Copy the code The code is as follows:
echo implode(",",$_POST['test']);
?>
When we output the content, we only need to use 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:
Untitled document html checkbox if you want to send it to php as a data group Script processing must be in the form of checkbox[]
//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 they are done, but they are easy to do, like this check box code.
*/
?>
The above introduces the detailed description of checkboxpreference php checkbox value, including the content of checkboxpreference. I hope it will be helpful to friends who are interested in PHP tutorials.