Home > Article > Backend Development > A simple way to get the checkbox value in php, get the checkbox in php_PHP tutorial
The example in this article describes a simple way to get the check box value in php. Share it with everyone for your reference, the details are as follows:
html:
<form id="form1" name="form1" method="post" action="checkbox.php"> <input type=checkbox name=checkbox[] value="1"> <input type=checkbox name=checkbox[] value="2"> <input type=checkbox name=checkbox[] value="3"> <input type=checkbox name=checkbox[] value="4"> <input type=checkbox name=checkbox[] value="5"> <input type="submit" name="button" id="checkbox" value="提交" /> </form>
php:
<?php $text1=$_POST['checkbox']; for($i=0;$i<count($text1);$i++) { $yourwant = $text1[$i]; echo $yourwant."<br/>"; } ?>
Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP socket usage", "Summary of PHP network programming skills", "Summary of PHP curl usage", "Comprehensive collection of PHP array (Array) operation skills" ", "PHP data structure and algorithm tutorial", "PHP mathematical operation skills summary", "php date and time usage summary", "php object-oriented programming introductory tutorial", "php string (string) usage summary", " PHP mysql database operation introductory tutorial" and "php common database operation skills summary"
I hope this article will be helpful to everyone in PHP programming.