But when you leave the loop very early with each, well that is a lot faster than going through all of them! (Hint, you are breaking out after an entry or two.)
UPDATE
My wording confused people. A foreach loop has to build a complete list of values before it does any processing. (Except for a hack for the range operator.) A while loop processes entries as it walks through the list. So the keys approach has to build the whole list even though most will be ignored, the each approach does not. But when you go through all of them, the each approach is doing basically what foreach did up front.
That make sense?
In reply to Re: each or keys?
by tilly
in thread each or keys?
by rdw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |