Re: Array as a session variable - Bug ?
| From: | Rasmus Lerdorf | Date: | Sun, 13 Aug 2000 01:13:46 +0000 |
| Subject: | Re: Array as a session variable - Bug ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11488@lists.php.net to get a copy of this message | ||
On Fri, 11 Aug 2000, Ovidiu EFTIMIE wrote:
> 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.
>
> $number=4;
> for($i=0;$i<$number;$i++){
> echo $i;
> //ses_packs - the session array
> while(list($key,$val)=each($ses_packs)){
> pg_exec("insert into tblc(pack) values('".$val."')");
> $aux[$key]=$val;
> }
> $ses_packs=$aux;
> }
>
> Any ideas ?
reset($ses_packs) before the second iteration.
-Rasmus