Home > Backend Development > PHP Tutorial > PHP method to obtain check box value and simple example

PHP method to obtain check box value and simple example

墨辰丷
Release: 2023-03-29 14:34:02
Original
1939 people have browsed it

This article mainly introduces the method of PHP to simply obtain the checkbox value, and briefly analyzes the implementation method of PHP passing the checkbox value in the form of an array. Friends in need can refer to the following

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>
Copy after login

php:

<?php
$text1=$_POST[&#39;checkbox&#39;];
for($i=0;$i<count($text1);$i++)
{
$yourwant = $text1[$i]; 
echo $yourwant."<br/>";
}
?>
Copy after login

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

php Detailed explanation of method examples for WeChat public platform configuration interface development program

PHP recursion Traverse the folder, remove comments and compress phpSource code

Detailed explanation of the method of PHP implementation of the previous article and the next article

The above is the detailed content of PHP method to obtain check box value and simple example. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template