Felix De Vliegher wrote:
> Hi all
> 
> I recently needed seek functionality in arrays, and couldn't find it
> in the regular set of array functions, so I wrote a function for it.
> Seek = getting an array value based on the position (or offset, if you
> want to call it like that), and not the key of the item)
> 
> Basically you can use it like this:
> $input = array(3, 'bar', 'baz');
> echo array_seek($input, 2); // returns 'baz'
> echo array_seek($input, 0); // returns 3
> echo array_seek($input, 5); // returns NULL, emits an out of range warning

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.

My 2 cents,
- Chris

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to