Basically I have an array of objects that I've managed to dump. I'm trying to figure out how I can get the values from the [options] object from a set objects and store them in an array
array(4) {
["size"]=>
object(WC_Product_Attribute)#2724 (1) {
["data":protected]=>
array(6) {
["id"]=>
int(0)
["name"]=>
string(4) "Size"
["options"]=>
array(3) {
[0]=>
string(6) "400 ml"
[1]=>
string(2) "1L"
[2]=>
string(2) "2L"
}
["position"]=>
int(0)
["visible"]=>
bool(true)
["variation"]=>
bool(false)
}
}
["fruit"]=>
object(WC_Product_Attribute)#2723 (1) {
["data":protected]=>
array(6) {
["id"]=>
int(0)
["name"]=>
string(5) "Fruit"
["options"]=>
array(8) {
[0]=>
string(17) "100% Orange Juice"
[1]=>
string(5) "Apple"
[2]=>
string(4) "Pear"
[3]=>
string(9) "Pineapple"
[4]=>
string(12) "Passionfruit"
[5]=>
string(15) "Red Dragonfruit"
[6]=>
string(13) "Baobab Powder"
[7]=>
string(17) "Grapeseed Extract"
}
["position"]=>
int(1)
["visible"]=>
bool(true)
["variation"]=>
bool(false)
}
}
["good-source-of-vit-c"]=>
object(WC_Product_Attribute)#2722 (1) {
["data":protected]=>
array(6) {
["id"]=>
int(0)
["name"]=>
string(20) "Good Source of Vit C"
["options"]=>
array(1) {
[0]=>
string(3) "Yes"
}
["position"]=>
int(2)
["visible"]=>
bool(true)
["variation"]=>
bool(false)
}
}
["fiber"]=>
object(WC_Product_Attribute)#2721 (1) {
["data":protected]=>
array(6) {
["id"]=>
int(0)
["name"]=>
string(5) "Fiber"
["options"]=>
array(1) {
[0]=>
string(3) "Yes"
}
["position"]=>
int(3)
["visible"]=>
bool(true)
["variation"]=>
bool(false)
}
}
}
I've tried doing a foreach to loop through each object but I've stumbled upon an error.
foreach ($productsArray as $i => $value) {
echo $value->options;
}
My objective is to get all the values from the [options] object store them in an array to be used.