search
Homephp教程php手册php读取checkbox值几种方法

php读取checkbox值几种方法

Jun 13, 2016 am 10:03 AM
phpbyvalueseveral kindsTutorialarraymethodObtainreadOptions

php教程获取checkbox多选项值时必须以数组形式了,下如test[]再用php post获取就ko了,下面看代码。








注意上面input的name属性,各个属性内容都一样,而且都是test[],加上[]的原因在于让test的内容变成数组形式传递。
checktest.php的代码内容如下:

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

print_r($str);

12345

哦。下面看我一朋友写的。

php代码

  
  
   

 

weeks后的中括号不可漏,否则用php获取的时候只能取到最后一个值。之后php就很好处理了,如下:

php代码

方法一:  
$weeks = $_post['weeks'];  
for($i=0;$i echo $weeks[1]."
";   
  
方法二:  
$array = $this->request->getparameter("weeks[]");  
$str =implode(',',$array);  
echo $str;  

 

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools