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 )

Exactly... it's not counting at all. If it were, you wouldn't get to so many iterations with only 2 entries in the array. I can't remember exactly how PHP stores arrays (some kind of bucket structure), but it's likely it traverses the items like a linked list using pointers from one to the next for efficiency.

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