Imagine a simple, but large array with keys 0 to 100000.
When doing a foreach loop of this array, is it possible to ‘seek’ ahead without doing something like:
foreach($array as $key=>$value){
if($key<10000){
continue;
}
}
We do this kind of operation once in a while thru our codebase. It seams like a bit of a waste of ticks to go thru each of the keys until key is greater then 10000.
Is this possible in php 5.4?
Thanks.
it was possible even in PHP 2.0FI or ALTAIR BASIC
No doubt some nitpickers will come to tell that doing
count($array)90000 times is a waste of ticks too.However, to get a real performance gain one have to avoid lengthy loops at all.