Hello everyone. I just need a little help.
I will post the code as it will be easier to understand once you have seen it.
foreach ($_SESSION['cart']['productid'] as $key => $value)
foreach ($_SESSION['cart']['quantity'] as $key2 => $value2)
foreach ($_SESSION['cart']['size'] as $key3 => $value3)
{
echo $value.' '.$value2.' '.$value3.'<br>';
}
What i am trying to do is print the product id, quantity, size on the same line for each product.
1234 2 small
4321 1 big
etc
I can understand why this dosent work, the loops repeat each other but i confused how to get my desired results. I can think of two solutions in theory.
1) do a multiple foreach (if one exist)
foreach ($_SESSION['cart']['productid'] as $key => $value; $_SESSION['cart']['quantity'] as $key2 => $value2)
I tried it but it said i had a syntax error which leads me to believe it cant be done that way.
2) A sorting function of some sort which uses the productid as the identifier to put all those arrays on the same line. a ksort function? (im probably WAY OFF!)
The whole code is an txt file attachment so you can troubleshoot my problem better.
THANKS IN ADVANCE!