On Tue, Mar 16, 2010 at 17:12, Mikko Koppanen <mkoppa...@php.net> wrote: > On Tue, Mar 16, 2010 at 2:12 PM, Christian Schneider > <cschn...@cschneid.com> wrote >> I thinks the user space implementation >> >> function array_seek($array, $pos) >> { >> $a = array_values($array); >> return $a[$pos]; >> } >> >> is simple enough to not add a native function for this. >> >> It might not be the most efficient way to do it but I doubt that it is >> something done frequently enough to justify another native function.
> slightly modified version of the original patch > http://valokuva.org/~mikko/array_seek.patch.txt. The difference to the I once porpoised similar patch to in_array, where it didn't reset the position after finding the "found element". In applications like PhD, this is extremely useful and safes us at least 10% overhead (at the time I benchmarked it with my patch to in_array()). I think we wound up with something like: while (list($key, $val) = each($array)) { if ($key == "foobar") { break; } } next($array); $current_index = current($array); To get the _next_ value after the known "currently known value (or key)". In an application like PhD (which already brought 24hours (DSSSL 24hours, xsltproc two formats compile time to) down to ~3-4minutes (3-5formats), 10% of _language_ overhead is extremely important, so I am all for a function that can do this (our/my goal is max 1minute... - sorry, HD read/write is still extremely expensive :(, it simply cant get faster then that afaict - if you have an idea; GSOC is open for experiments.. :D). -Hannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php