本文介绍了检索帖子数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用jQuery .serialize()发送所有数据的表单,其中有四个arrays qty[], etc,它将表单数据发送到sendMail页面,我想从数组中获取发布的数据.

I have a form that sends all the data with jQuery .serialize() In the form are four arrays qty[], etc it send the form data to a sendMail page and I want to get the posted data back out of the arrays.

我尝试过:

$qty = $_POST['qty[]'];
foreach($qty as $value)
{
  $qtyOut = $value . "<br>";
}

并尝试了此操作

for($q=0;$q<=$qty;$q++)
{
 $qtyOut = $q . "<br>";
}

这是正确的方法吗?

推荐答案

您的$_POST变量中包含[]-并非必需.您应该使用:

You have [] within your $_POST variable - these aren't required. You should use:

$qty = $_POST['qty'];

您的代码应为:

$qty = $_POST['qty'];

foreach($qty as $value) {

   $qtyOut = $value . "<br>";

}

这篇关于检索帖子数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 03:06