当我发布到数组时,只发布一个变量

时间:2014-02-25 17:44:50

标签: php html forms

我正在尝试将两个值'id'和'subscribed'从URL发送到数组中。正在正确检索'subscribed'值,但是只检索到第一个'id'值。

网址查询:

example.com/?
brands[0][id]=1&brands[0][subscribed]=true&
brands[1][id]=12&brands[1][subscribed]=true&
brands[2][id]=27&brands[2][subscribed]=true&
brands[3][id]=29&brands[3][subscribed]=false

预期结果:

Array
(
[0] => Array
    (
        [id] => 1
        [subscribed] => true
    )

[1] => Array
    (
        [id] => 12
        [subscribed] => true
    )

[2] => Array
    (
       [id] => 27
       [subscribed] => true
    )

[3] => Array
    (
        [id] => 29
        [subscribed] => false
    )

)

目前的结果:

Array
(
[0] => Array
    (
        [id] => 1
        [subscribed] => true
    )

[1] => Array
    (
        [subscribed] => true
    )

[2] => Array
    (
        [subscribed] => true
    )

[3] => Array
    (
        [subscribed] => false
    )

)

我尝试将'id'改为另一个单词,认为'id'可能是一个保留字,但这也不起作用。

关于在哪里继续寻找解决此问题的任何想法?

0 个答案:

没有答案