I'm trying to loop through a multi-dimensional array and I keep getting this error:
Warning: Invalid argument supplied for foreach() in foo.php on line 17
I am developing a shopping cart and want to put each purchases item in an array in the $SESSION. I have tried a hundred different ways of looping the $SESSION and none seem to work. Here are some snippets:
Add an Item:
$_SESSION['Products'][$_POST['ProductID']]['NUM'] = 1;
$_SESSION['NUMITEMS']++;
Display Cart:
foreach ($_SESSION['Products'] as $i ) {
echo "Current value $i<br>";
}