I have cart system which is saved in json array in database. I want to select all orders then all product_id's inside this array and show on page products which has most sells like bestsellers.
So far I'm able to take the array out and it's looks like this
array(2) {
[224]=> array(6) {
// data in which I'm not interested
}
}
array(2) {
[23]=> array(6) {
// data in which I'm not interested
}
}
array(2) {
[1]=> array(6) {
// data in which I'm not interested
}
}
array(2) {
[1231]=> array(6) {
// data in which I'm not interested
}
}
Each array(2) {...}
represent one order. I need this [224]
,[23]
.. because those are products ID. My question is how to know what property to select in my loop?
If it was like this
array(2) {
["id"]=> string(13) "32"
}
I will make something like $data->id
to get 32
This is how I got the array
foreach ($products as $item) {
$data = json_decode($item->details, true);
echo var_dump($data);
}
Any help is appreciated.
Update: with print_r($data);
they're looking like this
Array (
[224] => Array (
// data
)
)
Array (
[23] => Array (
// data
)
)
....
To me this is completely different because I don't know the name of column therefore I can't use array_column()