FairyBusiness
asked on
How to store a get variable into an array?
This seems like a rather silly question, but how do I store a $_GET variable in an array?
I have tried:
The problem with this is it only stores the current $_GET variable. When you move to a different page and click a different product it overwrites the variable.
So I want to put it in the array (store past $_GET variables) not have it be the only thing in the array. Anyone know how to do this??
I have tried:
$bag = get_item();
$_SESSION['cart'] = array();
$_SESSION['cart'] = [$bag];
The problem with this is it only stores the current $_GET variable. When you move to a different page and click a different product it overwrites the variable.
So I want to put it in the array (store past $_GET variables) not have it be the only thing in the array. Anyone know how to do this??
$_SESSION['cart'] = $_GET['item'];
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks :)
Of course you would want to track the number of items in the cart by doing something like setting $_SESSION['numitems'] so you know what array item you are working with.
ASKER
hmmm ok that can be my next question jason if you want to answer it!