Re: Foreach question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux