I just have a little question, I can’t find any answer since I don’t know exactly how to formulate it on Google.
So I have this array returned from a query:
Array
(
[0] => Array
(
[aad3177ec0cbced7a15fae003bdd0ff3] => Array
(
[rowid] => aad3177ec0cbced7a15fae003bdd0ff3
[id] => 21
[qty] => 1
[price] => 176
[name] => KRUPS YY1305
[image] => utilities/images/products/p2070396dt.jpg
[description] => Menu simplifié pour une convivialité optimale.
[subtotal] => 176
)
)
)
And I want to get all the information rowid, id, qty … to store it through a foreach loop in another variable without knowing the name of the second array : ‘aad3177ec0cbced7a15fae003bdd0ff3’. I just want to retrieve articles from a cart stored in a database when user logged out.
So how can I say something like :
echo $myArray['0'][theNumberGoesHereAutomatically]['price'];
Ideally, my code would look like that :
foreach ($data2 as $cart){
$data = array(
'rowid' => $cart_unserialized[$token]['aad3177ec0cbced7a15fae003bdd0ff3']['rowid'],
'id' => $cart_unserialized[$token]['aad3177ec0cbced7a15fae003bdd0ff3']['id'],
'qty' => $cart_unserialized[$token]['aad3177ec0cbced7a15fae003bdd0ff3']['qty'],
'price' => $cart_unserialized[$token]['aad3177ec0cbced7a15fae003bdd0ff3']['price'],
'name' => $cart_unserialized[$token]['aad3177ec0cbced7a15fae003bdd0ff3']['name'],
'image' => $cart_unserialized[$token]['aad3177ec0cbced7a15fae003bdd0ff3']['image'],
'description'=> $cart_unserialized[$token]['aad3177ec0cbced7a15fae003bdd0ff3']['description'],
);
$this->cart->insert($data2);
$token++;
};
without knowing the aad3177ec0cbced7a15fae003bdd0ff3.
Any ideas? Thanks 🙂
You can do this easily with:
$varnamewill containaad3177ec0cbced7a15fae003bdd0ff3.