I'm working with SunShop attempting to build a custom reporting script for my client. I'm having a difficult time understanding how to run a foreach() statement to pull out any chosen info from this array. For instance, I would like to pull out each option name & value.
Goal:
echo $data['options']['name']
echo $data['options']['value']
I've tried several methods of implementing foreach() to loop through and display my results, but it fails every time either telling me I'm not unserializing correctly, or that there's an undefined object. Can any of you shed light on this? I certainly don't know enough about arrays.
Also, I think it's worth mentioning, that I'm not dealing with sessions. I'm building this outside of SunShop just to run on occasion to pull reports when requested.
How I get my array:
<?php
$array=unserialize(base64_decode($data));
var_dump($array);
?>
Array dump:
object(__PHP_Incomplete_Class)[1]
public '__PHP_Incomplete_Class_Name' => string 'item' (length=4)
public 'id' => int 655
public 'quantity' => float 3
public 'options' =>
array
0 =>
object(__PHP_Incomplete_Class)[2]
public '__PHP_Incomplete_Class_Name' => string 'option' (length=6)
public 'id' => string '487' (length=3)
public 'product' => string '655' (length=3)
public 'name' => string 'Choose Brand' (length=12)
public 'value' => string 'Brand Name' (length=10)
public 'valueid' => string '2026' (length=4)
public 'weight' => string '0' (length=1)
public 'price' => string '0' (length=1)
public 'desc' => string '' (length=0)
public 'sku' => string '' (length=0)
1 =>
object(__PHP_Incomplete_Class)[3]
public '__PHP_Incomplete_Class_Name' => string 'option' (length=6)
public 'id' => string '488' (length=3)
public 'product' => string '655' (length=3)
public 'name' => string 'Choose Size & Color' (length=19)
public 'value' => string 'Chocolate - Medium' (length=18)
public 'valueid' => string '2022' (length=4)
public 'weight' => string '0' (length=1)
public 'price' => string '0' (length=1)
public 'desc' => string '' (length=0)
public 'sku' => string '' (length=0)
public 'regid' => string '' (length=0)