I am trying to get certain value from the stack below:
[
{
"o_id": "593ff39d86a43",
"o_name": "Black",
"o_picture": "/puma_black.jpeg",
"o_sizes": {
"1": {
"o_price": "",
"o_quantity": "7",
"o_size": "S"
},
"2": {
"o_price": "",
"o_quantity": "4",
"o_size": "M"
},
"3": {
"o_price": "",
"o_quantity": "5",
"o_size": "L"
}
}
},
{
"o_id": "593ff39d86a4d", <-- FROM THIS sub array
"o_name": "White",
"o_picture": "/puma_white.jpeg",
"o_sizes": {
"4": {
"o_price": "",
"o_quantity": "5",
"o_size": "S"
},
"5": {
"o_price": "",
"o_quantity": "6", <- i need to find this
"o_size": "M"
}
}
}
]
So far by this function
$key = array_search([STACK], array_column("593ff39d86a4d", 'o_id'));
I managed to get this part:
{
"o_id": "593ff39d86a4d", <-- FROM THIS sub array
"o_name": "White",
"o_picture": "/puma_white.jpeg",
"o_sizes": {
"4": {
"o_price": "",
"o_quantity": "5",
"o_size": "S"
},
"5": {
"o_price": "",
"o_quantity": "6", <- i need to find this
"o_size": "M"
}
}
So i set the above to:
$sizes = $product->options[$key]['o_sizes'];
$sizes is now the array in which i need to find exactly size M and the quantity of this size. I tried to do another array_search, however i can't seem to get it. How do i achieve this from here?