Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47371 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53820 invoked from network); 17 Mar 2010 16:27:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Mar 2010 16:27:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=frederic.hardy@mageekbox.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=frederic.hardy@mageekbox.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mageekbox.net from 91.121.185.56 cause and error) X-PHP-List-Original-Sender: frederic.hardy@mageekbox.net X-Host-Fingerprint: 91.121.185.56 63.mail-out.ovh.net Received: from [91.121.185.56] ([91.121.185.56:44281] helo=63.mail-out.ovh.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/99-05162-6F201AB4 for ; Wed, 17 Mar 2010 11:27:36 -0500 Received: (qmail 3034 invoked by uid 503); 17 Mar 2010 16:30:57 -0000 Received: from b6.ovh.net (HELO mail408.ha.ovh.net) (213.186.33.56) by 63.mail-out.ovh.net with SMTP; 17 Mar 2010 16:30:57 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 17 Mar 2010 16:27:31 -0000 Received: from o2.noparking.net (HELO diablo.local) (fhardy%noparking.net@88.181.202.210) by ns0.ovh.net with SMTP; 17 Mar 2010 16:27:31 -0000 Message-ID: <4BA102F2.1000405@mageekbox.net> Date: Wed, 17 Mar 2010 17:27:30 +0100 User-Agent: Thunderbird 2.0.0.23 (X11/20100209) MIME-Version: 1.0 To: Felix De Vliegher CC: PHP internals References: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> In-Reply-To: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 212513608693912221 X-Ovh-Remote: 88.181.202.210 (o2.noparking.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N Subject: Re: [PHP-DEV] array_seek function From: frederic.hardy@mageekbox.net (Frederic Hardy) 2010/3/16 Felix De Vliegher : > 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 was wondering if it's useful to add this to the family of array functions. I know there is a somewhat similar thing in SPL (ArrayIterator::seek), but that doesn't work exactly like what I was aiming for. > > Attached is a patch for the function against the 5.3 branch. If approved, I could add it to svn + testcases + docs. Feedback please :-) > > > Kind regards, > Felix Hello Felix ! Why not use arrayIterator::seek() ? Best regards, Fred -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php