Several ways to read checkbox value in php_PHP tutorial

WBOY
Release: 2016-07-13 16:59:12
Original
1279 people have browsed it

The PHP tutorial must be in the form of an array when obtaining the checkbox multi-option value. The following is test[] and then use PHP post to obtain it. See the code below.








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:

$str =implode(',',$_post['test']);

print_r($str);

12345

Oh. Below is what a friend of mine wrote.

php code




The square brackets after weeks cannot be missed, otherwise only the last value can be obtained when using PHP. After that, php will be easy to handle, as follows:

php code

Method 1:
$weeks = $_post['weeks'];
for($i=0;$i echo $weeks[1]."
";

Method 2:
$array = $this->request->getparameter("weeks[]");
$str =implode(',',$array);
echo $str;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631344.htmlTechArticlephp tutorial When obtaining the checkbox multi-option value, it must be in the form of an array, as shown below test[] and then use php post to obtain it That’s it, look at the code below. form method=post action=checktest.php input name=test...
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