解析错误:语法错误,意外'=>' > (T_DOUBLE_ARROW),期待

时间:2017-03-30 22:40:09

标签: php

  

我有此错误消息“解析错误:语法错误,意外'=>'   (T_DOUBLE_ARROW),期待')'“,因为我想创建2D数组以将2个密钥传递给foreach循环。

$productIds = array
  (
  [0] => Array
        (
            [SKU] => 'xx'
            [Price] => 22

        )

    [1] => Array
        (
            [SKU] => 'bb',
            [Price] => 15,

        )

    [2] => Array
        (
            [SKU] => 'cc',
            [Price] => 5,

        )
    [3] => Array
        (
            [SKU] => 'tt',
            [Price] => 17,

        )

1 个答案:

答案 0 :(得分:0)

我认为在创建该数组时,您在数组中缺少逗号,它应该是:

 Array
    (
        [SKU] => 'xx',
        [Price] => 22

    )

而不是

 Array
    (
        [SKU] => 'xx'
        [Price] => 22

    )