【问题标题】:How to pass an array in to an array to PHP a server?如何将数组传递给 PHP 一个服务器的数组?
【发布时间】:2018-10-19 10:36:10
【问题描述】:

我的 html 视图中有下一个多个字段:

<select multiple="multiple" name="search[cpuUsage[]]"
    id="search_cpu_usage"
    class="form-control">
    {% for statu in status %}
        <option value="{{ statu }}">{{ statu }}</option>
    {% endfor %}
</select> 

我需要用户选择的所有可能值,我尝试保存在search[cpuUsage[]] 中,但这不起作用,因为php 只获取最后选择的值。如果我只使用 cpuUsage[] 而不使用 search[] 效果很好。

为了发送到服务器,我使用jquery.serialice

知道如何工作search[cpuUsage[]]

【问题讨论】:

  • cpuUsage[] 已经是一个数组了,为什么还需要search 数组?

标签: php jquery html symfony


【解决方案1】:

您需要将name 属性作为数组

所以改变

name="search[cpuUsage[]]"

收件人:-

name="search[cpuUsage][]" //or name="search[]" or name="cpuUsage[]"

你很高兴

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-17
    • 1970-01-01
    • 2020-04-18
    • 2012-04-04
    • 1970-01-01
    • 2018-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多