I print a PHP array with var_export
and I get something that looks like this :
array (
0 =>
array (
'id' => 1,
'type' => 'POSTER',
'brand' => NULL,
'model' => 'Enhanced Matte Paper Poster (in)',
'image' => 'https://d1yg28hrivmbqm.cloudfront.net/products/1/product_1552909388.jpg',
'variant_count' => 11,
'currency' => 'USD',
I try to access elements of array using this :
//Get product list
$products = $pf->get('products');
highlight_string(var_export($products, TRUE));
foreach($products as $product){
echo $product[0]->id
}
I get 2 errors
Notice: Undefined offset: 0
Notice: Trying to get property of non-object
I did read this here but I think I'm doing something wrong. What I am missing?