RE: session

From: Date: Mon, 08 Jan 2001 10:05:31 +0000
Subject: RE: session
Groups: php.general 
Request: Send a blank email to php-general+get-33208@lists.php.net to get a copy of this message
foreach works on a copy of the array ... therefore, as you found, chnages are not made to the original. see: http://ch.php.net/manual/control-structures.foreach.php Tim Ward Senior Systems Engineer Please refer to the following disclaimer in respect of this message: http://www.stivesdirect.com/e-mail-disclaimer.html > -----Original Message----- > From: n e t b r a i n [mailto:net-brain@net-brain.net] > Sent: 07 January 2001 04:24 > To: php-general@lists.php.net > Subject: session > > > Hi all, > I've a problem manipulating a variable stored in session ... > > The variable is an array like this: > > $item[108]=3; > $item[56]=1; > > //the index is the id_product and var value is the number of items > > All works fine except when I try to modify them in bulk, e.g. > using a simple > loop like this: > > foreach($item as $key=>$val){ > if($val>0){ > $item[$key]=$val; > } else { > unset($item[$key]); > } > } > session_register("item"); > > With this code, no changes are applies ... > (these values are sent using a simple form via post method > like this: <input > type=text name=item[108] ...>). > > Any help or suggestion are very appreciated. > Many thanks in advance. > max > > >

« previous php.general (#33208) next »