Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47365 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42722 invoked from network); 17 Mar 2010 16:00:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Mar 2010 16:00:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=patrick.allaert@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.218 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 209.85.219.218 mail-ew0-f218.google.com Received: from [209.85.219.218] ([209.85.219.218:55806] helo=mail-ew0-f218.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AE/47-05162-78CF0AB4 for ; Wed, 17 Mar 2010 11:00:10 -0500 Received: by ewy10 with SMTP id 10so609591ewy.32 for ; Wed, 17 Mar 2010 09:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=RDhb77VOQK/UpQwS4B39DGzba75xt2gQWiCRrH9vzf8=; b=WHfGq7kUa1X0iNQm08pP887GchuyOdfzL+evxdZ4gs1hoQsW7UJKhIv9cxc5N/KJhA FlGi4qfBi5rxUpnUDNnCeTBb6ddKXhBKaDpDenzu0PXWTTamO8rRco8wo5+fql3vSgvc WoQwNp2G3U6C5OA7Fg5MJJoEd+eiS01Ye6Wvo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=P5wE3zSMoMqN2ik0DcrTwyA9EWZxllaLR/Er2rsq3MKRUwpC7td/KEE5Y4JyDHi9mL oMlweOaNsJhU1EgqKUQ5uH5qEUzbS/ZuMo094I4EZLxg2ZMe2G+2SguxXnt4LqyRt3cx KKPwXxSGYENpDZ/0+aYAETwSFqZgQOVofB/R8= MIME-Version: 1.0 Received: by 10.216.87.75 with SMTP id x53mr595897wee.144.1268841600439; Wed, 17 Mar 2010 09:00:00 -0700 (PDT) In-Reply-To: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> References: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> Date: Wed, 17 Mar 2010 17:00:00 +0100 Message-ID: To: Felix De Vliegher Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] array_seek function From: patrick.allaert@gmail.com (Patrick ALLAERT) 2010/3/16 Felix De Vliegher : > Hi all > > I recently needed seek functionality in arrays, and couldn't find it in t= he regular set of array functions, so I wrote a function for it. (Seek =3D = getting an array value based on the position (or offset, if you want to cal= l it like that), and not the key of the item) > > Basically you can use it like this: > $input =3D 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 warnin= g > > I was wondering if it's useful to add this to the family of array functio= ns. 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 Hi Felix, What about adding a new int parameter to PHP array function: next() and prev() instead of adding a new one? Cheers, Patrick