Re: Silly varible question
| From: | Brad Bonkoski | Date: | Thu, 13 Jul 2006 12:11:23 +0000 |
| Subject: | Re: Silly varible question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-239407@lists.php.net to get a copy of this message | ||
Why not just have another array...
$bag = array();
$item[] ....
array_push($bag, $item);
then store the bag in the session.
so, you would have count($bag) items in your shopping cart, and you would be able to easily access them.
Just a thought, instead of munging variable names.
-B
Ed Curtis wrote:
I know this is probably simple as all get out but it's early and I can't find an answer anywhere after searching for a while.... I need to assign a number to a variable and then use that variable in a session to store an array. It's for a shopping cart system I'm building. What I've got is: $count = 1; //First item in the cart passed from form to form $item = array(); $item[] = $_POST['phone']; $item[] = $_POST['category']; $item[] = $_POST['copy']; $item[] = $_POST['pic_style']; $item[] = $cost; $item[] = $image; session_register('item'); In the session the item is known as 'item'. What I need for it to be is 'item1' so when the customer chooses another product I can increase $count by 1 and have the next array with values stored as 'item2'. Thanks for any help, Ed