Hi

As SEEK_END only makes sense with zero or negative offsets (for arrays anyway), 
I've come up with an implementation for SEEK_END:
http://phpbenelux.eu/array_seek.patch.txt

So you can do:
$arr = array('a', 'b', 'c', 'd');
echo array_seek($arr, -2, SEEK_END); // outputs 'b'
echo array_seek($arr, 0, SEEK_END); // outputs 'd'


Cheers,
Felix

On 16-mrt-2010, at 19:07, Mikko Koppanen wrote:

> On Tue, Mar 16, 2010 at 4:22 PM, Derick Rethans <der...@php.net> wrote:
>> I was also thinking, can we just make this work just like fseek (with a
>> "whence" parameter) as well? (http://uk3.php.net/fseek)
> 
> Hi,
> 
> not sure how SEEK_END is supposed to work with arrays but here is
> SEEK_SET and SEEK_CUR (with positive and negative offset)
> http://valokuva.org/~mikko/array_seek_whence.patch.txt
> 
> -- 
> Mikko Koppanen


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

Reply via email to