Re: Weird nested while loop problem

From: Date: Wed, 17 Jan 2001 22:00:06 +0000
Subject: Re: Weird nested while loop problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-35177@lists.php.net to get a copy of this message
> > What I'm getting is that the inner while loop executes on the first > > execution of the outer while, and then not at all. How would I get > > it to execute each time? > > Coming from a perl background, I got stuck there too when I started using > PHP. PHP has this odd notion of an array pointer. After the first time you > loop through the array, the pointer is at the end, so the second loop won't > really do anything. Use the reset frunction to reset the array pointer to > the first element. The array pointer can be pretty useful. ie. give me the second last element of an array: end($arr); echo prev($arr); Or have it tell you what the index is at the second last element: end($arr); prev($arr); echo key($arr); and the index before that one: prev($arr); echo key($arr); Perl has these too, they just aren't user accessible. -Rasmus

« previous php.general (#35177) next »