1
array (
  '_attributes' => 
  array (
    'name' => 'Rothco Product API - Variations',
  ),
  'item_variations' => 
  array (
    0 => 
    stdclass::__set_state(array(
       'item_variation_id' => 2,
       'item_index' => 3146,
       'rothco_item_no' => '10002',
       'upc' => '023063601212',
       'inventory' => 99,
       'created_date' => '2014-11-28 10:06:45.000',
       'weight' => '.4000',
       'image_filename' => '10002-A.jpg',
       'catalog_page_no' => 183,
       'msrp' => '20.9900',
       'map' => '.0000',
       'diameter' => '',
       'price' => '8.100000',
       'case_price' => NULL,
       'case_quantity' => NULL,
       'statuses' => '',
    )),
  ),
)

This is my array $list.

I want to access 'item_variations' value from this array,

but if I try $list['item_variations'], or $list->['item_variations']

it is not working

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141

1 Answers1

1

If you want to reach just item_variations then

echo $list['item_variations'];

is sufficient. Things get more tricky if you would like to i.e. get value if created_date from your sample data as you got mix of arrays and objects so that require different access:

echo $list['item_variations'][0]->created_date;

which would output

2014-11-28 10:06:45.000
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141