These multi-dimensional arrays are giving me a headache. Here's the array, and I'm trying to pull just the [asin] value. This is from a Wordpress plugin, and here's how I dumped the array:
print "<pre>";
print_r($this);
print "</pre>";
*output:
THEPLUGIN_Template_Handler Object
(
[inline:THEPLUGIN_Template_Handler:private] =>
[is_widget:THEPLUGIN_Template_Handler:private] =>
[timestamp_template:THEPLUGIN_Template_Handler:private] => 0
[store] =>
[atts] => Array
(
[template] => widget-vertical-custom
[star_rating_size] => large
[image_size] => large
)
[type] => box
[items] => Array
(
[B009FUF6DM] => Array
(
[id] => 18
[status] => active
[asin] => B009FUF6DM
....
I tried:
echo $this->items[0];
echo $this->items[0][0];
echo $this['items'][0];
echo $this['items']['B009FUF6DM']['asin'];
echo $this->items['B009FUF6DM']['asin'];
To clarify, if I use this code echo $this->items['B009FUF6DM']['asin'];
it does display the ASIN, but the problem is that the 'B009FUF6DM' value changes. So I need to account for that by just accessing the [0] index of that array, or something.
Similar to How to get data from array in object and PHP Multidimensional Array Searching (Find key by specific value)
Thanks for any help or direction! :)
The top level is an object, so to access items you need to access it as an attribute.
$this->items['B009FUF6DM']['asin'];
From somewhere else, if the attribute is private you need to provide a public getter for the attribute.