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.
Hi, slightly modified version of the original patch http://valokuva.org/~mikko/array_seek.patch.txt. The difference to the original is that the iterator position is left where the user seeked to. So something like following should work: <?php $arr = array("the", "brown", "fox", "and", "so", "on"); echo array_seek($arr, 1) . "\n"; // brown echo next($arr) . "\n"; // fox ?> Not sure how useful it is to have this in core but I do remember for looking for a seek function for arrays before. -- Mikko Koppanen -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php