Thanks, that was interesting :) I think I got one step further in understanding PHP :) BTW, I've changed the loop to 'for' and it's working well :) -----Original Message----- From: Robert Cummings [mailto:robert@xxxxxxxxxxxxx] Sent: Tuesday, July 05, 2011 4:45 PM To: Dajka Tamás Cc: php-general@xxxxxxxxxxxxx Subject: Re: Foreach question On 11-07-05 10:39 AM, Dajka Tamás wrote: > Ok, but if it would be that way I shouldn't get '122334455' for second output, no? The item count increments with every iteration of the loop. > > Or you're saying that, it checks for an existance of nextitem before every loop, and that will fail with just one element, but will always return true with two elements? ( since the first elements copy is pushed as third element, etc ) BTW, there are reasons you might calculate next item before iterating. If the current iteration removes the current item, then nextItem would still be valid (theoretically :). It's more often the case you might remove the current item, than try to remove the next item in a foreach iteration. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php