Re: array_seek function

From: Date: Wed, 17 Mar 2010 15:07:36 +0000
Subject: Re: array_seek function
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-47359@lists.php.net to get a copy of this message
On Wed, Mar 17, 2010 at 4:02 PM, Daniel Convissor
<danielc@analysisandsolutions.com> wrote:
> Hi:
>
>> $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?

Please double check what the patch does, test it, and think again
about this question (hint: pos != key) :)

Cheers,

> $input = array(3, 'bar', 'baz');
> echo $input[2]; // returns 'baz'
> echo $input[0]; // returns 3
> echo $input[5]; // returns NULL, Notice: Undefined offset: 5
>
> --Dan
>
> --
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>            data intensive web and database programming
>                http://www.AnalysisAndSolutions.com/
>  4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org


Thread (34 messages)

« previous php.internals (#47359) next »