0

I have an array that holds a number of arrays. I access them in turn e.g.

print_r($orderData[0]) and the output is:

Array (
  [201] => Array (
    [name] => SuperMarket One
    [type] => line_item
    [item_meta] => Array (
      [_qty] => Array (
        [0] => 1
      )
    )
  )
)

My issue is, I can't seem to access anything e.g. print_r($orderData[0]['name']) gives me:

Notice: Undefined index: name in /Path

Likewise, I can't use print_r($orderData[0][0]) etc.

I must be missing something quite obvious here.

Tom Lord
  • 27,404
  • 4
  • 50
  • 77
Colin
  • 675
  • 1
  • 11
  • 32

2 Answers2

1

You have another array in it with the key 201. Use PHP's function var_dump($orderData[0]) to view the complete structure of your array.

Remco K.
  • 644
  • 4
  • 19
0

Access it using

$orderData[0][201]['name']
SanketR
  • 1,182
  • 14
  • 35