收藏文章 楼主

php 怎么获取表单中的多条数据

版块:php   类型:普通   作者:小绿叶技术博客   查看:1703   回复:0   获赞:0   时间:2021-11-24 21:26:35

<form name="form1" method="post" action="test.php?action=ok">

1.<input type="text" name="contents[]" value="">

2.<input type="text" name="contents[]" value="">

3.<input type="text" name="contents[]" value="">

<input type="submit" value="提交">

</form>




#------------ 另外一个 huoq.php 文件 ----------#


<?php

#-------- get 获取 参数 -------#

if($_GET['action'] == 'ok'){

$contents = $_POST['contents[]'];

}


#------- 进行遍历打印 -----#

$count=count($_POST["contents"]);

for($i = 0; $i<count($_POST["contents"]); $i++){

echo $_POST["contents"][$i]."拼接字符串".$i;

}


#-------- 指定数组赋值 -------#

$ip=$_POST["contents"][0];

$ipok=$_POST["contents"][1];

$details=$_POST["contents"][2];

echo "数组获取到值"."$ip"."$ipok"."$details";


?>


提供企业建站服务,免费网防系统,提交信息登录 http://yundun.ddoss.cn 邮箱: proposal@ddoss.cn 
回复列表
默认   热门   正序   倒序

回复:php 怎么获取表单中的多条数据

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息