RE: [PHP] Sessions and Arrays
| From: | Mark Cubitt | Date: | Tue, 08 Apr 2003 16:15:38 +0000 |
| Subject: | RE: [PHP] Sessions and Arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142898@lists.php.net to get a copy of this message | ||
don't know if this will help but I used something like this
function addtocart ($itemno, $amount) {
if ($amount != '') {
if (session_is_registered("cart")){
$tempcart = $_SESSION['cart'];
$tempcart{$itemno} = $tempcart{$itemno} + $amount;
$_SESSION['cart'] = $tempcart;
}
else
{
$tempcart{$itemno} = $amount;
session_register("cart");
$_SESSION['cart'] = $tempcart;
}
} //end if ($amount != '')
} // end function addToCart
if you didn't guess it is a function to add to a shoping cart using an array
as a session var
> -----Original Message-----
> From: Erich Kolb [mailto:ekolb@randbreceivables.com]
> Sent: 08 April 2003 17:03
> To: php-general@lists.php.net
> Subject: [PHP] Sessions and Arrays
>
>
> Lets say I have:
> $_SESSION['var'] = array(1,2,3,4,5);
>
> My understanding is that this would turn $_SESSION['var'] into an
> array. So
> how do I get the value from array(2) into a variable?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> ******************************************************************
> ************
> This email has been virus checked by the Eclipse Internet
> MAILsafe service
> ******************************************************************
> ************
> www: http://www.eclipse.net.uk/ email:
> eclipse@eclipse.net.uk
> ******************************************************************
> ************
>
>