表单可以把自己定义成数组形式,这样我们就能利用post接收用户多选过来的值了,下面一聚教程小编给各位整理了几个例子。
今天写php的时候发现$_POST["arr"]无法获取参数arr的数组,记录一下。
例如有以下表单需要提交:
代码如下 | 复制代码 |
|
使用$_POST["arr"]只能获得最后选择的复选框的值,要获得全部选中的复选框的值需要把表单修改成下面:
代码如下 | 复制代码 |
|
这样就可以使用$_POST["arr"]获得全部选中的checkbox的值,那这样获取值了我们要怎么解析出来呢。
第一中方法
代码如下 | 复制代码 |
test1.php
foreach($_POST as $key => $val){ |
?>
第二种用法
test3.php
代码如下 | 复制代码 |
if(isset($_POST['submit'])){ |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools