I have a little problem with a simple loop. I have a data like this :
$PRODUCT = [
'title' => 'Blouse',
'lines' => [
'variants' => [
[
'price' => 112.34,
'options' => [
'size' => 'small',
'color' => 'yellow',
]
],
[
'price' => 156.33,
'options' => [
'size' => 'small',
'color' => 'blue',
]
],
],
]
I need to create a new table like this:
$options => [
'size',
'color'
]
I'm trying to get only to array with key 'options' in my loop, and I even have data which I need, but I have warning:
Warning: Illegal string offset 'options'
My loop looks like this:
$options = [];
foreach ($PRODUCT['lines'] as $variant){
foreach ($variant as $item) {
$options[] = $item['options'];
}
}
Where is my mistake? I know that 'price' is not an array, but what does to have no warnings in this case?