Re: array_seek function

From: Date: Wed, 17 Mar 2010 15:11:34 +0000
Subject: Re: array_seek function
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-47360@lists.php.net to get a copy of this message
On Wed, 17 Mar 2010, Daniel Convissor wrote:

> > $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
> 
> Why waste time calling a function when this can be done right now by 
> acting on the array itself?

Because array keys can be sparse and don't have to be "in order".

regards,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug


Thread (34 messages)

« previous php.internals (#47360) next »