【问题标题】:PHP post with square brackets not creating array带有方括号的PHP帖子不创建数组
【发布时间】:2014-04-22 07:30:04
【问题描述】:

我已经在表格中使用了几次方括号,但是我很困惑,因为我现在正在使用 Twitter BootStrap 工作(这会有什么不同吗?)没有发送数据(!) - 12 年的编码和现在我在问这个愚蠢的问题。

我通常可以做的是手动(或通过循环) echo $_POST['itemnum'][0] / $_POST['itemnum'][1] / etc - 但它回来是空的..

<form  method="POST" action="'.phpself.'" class="form-horizontal" role="form">
...(table with 3 identical rows)..

<tr>
            <td >
            <input type="text" name="itemnum[]" class="form-control" id="inputEmail3" placeholder="Item #"></td>
            <td ><input type="text" name="itemdesc[]" class="form-control" id="inputEmail3" placeholder="Description"></td>
            <td ><input type="number" name="itemqty[]"  class="form-control"  style="max-width:80px;display:inline"  placeholder="Qty"></td>
            </tr>
....

</form>

var_dump:

array(5) { ["itemnum"]=> string(0) "" ["itemdesc"]=> string(0) "" ["itemqty"]=> string(0) "" ["message"]=> string(24) " d hef s s dvs sd vsd vs" ["submitRFQ"]=> string(0) "" } 

【问题讨论】:

  • 您是否使用 Ajax 发送此表单?
  • 不 - 定期提交..
  • 我建议您使用浏览器开发工具的网络检查器并确保它正确提交。
  • 你在扔什么?是处理后的值还是 $_POST 变量的内容?
  • 我没有看到您的代码存在问题。有时您的标签未正确关闭也可能是原因。你能粘贴完整的 HTML 吗?

标签: php post var-dump square-bracket


【解决方案1】:

对不起,我有一个 CleanFormPost() 函数不适合多维数组。再次道歉并再次感谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多