Rãspuns: [PHP] Array as a session variable - Bug ?

From: Date: Fri, 11 Aug 2000 14:57:27 +0000
Subject: Rãspuns: [PHP] Array as a session variable - Bug ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-11337@lists.php.net to get a copy of this message
It worked fine .Thanks Robin. Ovidiu -----Mesaj original----- De la: php-general-return-11333-eovidiu=rds.ro@lists.php.net [mailto:php-general-return-11333-eovidiu=rds.ro@lists.php.net]În numele Robin Vickery Trimis: Friday, August 11, 2000 5:41 PM Catre: php-general@lists.php.net Subiect: Re: [PHP] Array as a session variable - Bug ? eovidiu@rds.ro ("Ovidiu EFTIMIE") writes: > Greetings, > I'm working with php 4.0(1-08-2000 snapshot) and I use an array as an > session variable.I've noticed that I can read the array only once, and at > the second read the array is empty . > For example > $number=4; > for($i=0;$i<$number;$i++){ > echo $i; > //ses_packs - the session array > while(list(,$val)=each($ses_packs)){ > pg_exec("insert into tblc(pack) values('".$val."')"); > } > } > At the first iteration the values are inserted but at the second one the > ses_packs is empty. > Of course I can use an work around but I was wondering if this a normal > behaviour or it's a bug. It's not empty, you've just got to the end of it. You need to go back to the start of the array with reset(). It's in the manual at http://uk.php.net/manual/function.reset.php3 $number=4; for($i=0;$i<$number;$i++){ echo $i; //ses_packs - the session array reset($ses_packs); while(list(,$val)=each($ses_packs)){ pg_exec("insert into tblc(pack) values('".$val."')"); } } -- Robin Vickery............................................... Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK Email: robin@planet-three.net Phone: +44 (0)794 670 6395 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#11337) next »