Reputation: 13527
I have the following array called "$order" (as printed out by "print_r"):
stdClass Object
(
[products] => Array
(
[0] => stdClass Object
(
[data] => Array
(
[attributes] => Array
(
[ID] => Array
(
[0] => 57
)
)
)
)
)
)
My question is, how do I reference "57"? I thought it would be something like this:
$order->products[0]->data[attributes][ID][0];
But this doesn't work. What am I missing?
Upvotes: 0
Views: 979
Reputation: 17836
You're missing some quotes for the array keys. Otherwise it makes PHP think that attributes
or ID
is a constant (define('ID', 'foobar'); echo ID;
).
$order->products[0]->data['attributes']['ID'][0];
Upvotes: 2
Reputation: 13527
Nevermind. It's like this: $order->products[0]->data["attributes"]["ID"][0];
Upvotes: 0