$ _POST来自html表单的数组 [英] $_POST Array from html form

查看:72
本文介绍了$ _POST来自html表单的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从多个复选框(id [])发送数据并在php中创建一个数组"info",以允许我为每个值运行一个脚本(但是值的数量可能会每次更改),但是首先正在尝试显示每个数组值的内容.我不太确定如何在阵列填充行中将所有内容保存到阵列中.

I am trying to send data from multiple checkboxes (id[]) and create an array "info" in php to allow me to run a script for each value (however the quantity of values may change each time) however first I am trying to display the content of each array value. I am not quite sure how to put my array populating line to save all the content to the array.

HTML

echo("<input name='id[]' type='checkbox' value='".$shopnumb."'>");

我目前希望的处理代码是-

my hopeful processing code currently is -

$info=$_POST['id[]'];
Echo(array_values($info));

我需要做些什么才能使表单复选框中的邮件发送内容填充数组信息

what do I need to do to make the content sent by post from the form checkboxes populate the array info

非常感谢您的帮助

为澄清起见进行了编辑.

edited for clarification.

推荐答案

更改

$info=$_POST['id[]'];

$info=$_POST['id'];

通过在表单字段名称的末尾添加[],PHP将自动将这些变量转换为数组.

by adding [] to the end of your form field names, PHP will automatically convert these variables into arrays.

这篇关于$ _POST来自html表单的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆