Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47306 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2718 invoked from network); 16 Mar 2010 13:47:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2010 13:47:22 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.220.215 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 209.85.220.215 mail-fx0-f215.google.com Received: from [209.85.220.215] ([209.85.220.215:51855] helo=mail-fx0-f215.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/0E-15129-8EB8F9B4 for ; Tue, 16 Mar 2010 08:47:21 -0500 Received: by fxm7 with SMTP id 7so1350462fxm.23 for ; Tue, 16 Mar 2010 06:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=LQtyxOa+WPKlfYicLFZJNOpElM1LLK5y8rADep0bVfs=; b=rj0AGCPEKdgbegDRJFfZ7EsiV8KUsHdEA2sLY5+bll0MipSiWUS5bqcyREyKVdLOkE zsXC/DdnZv7OUXDqqdbZBUmF7aA2ujQSRg7+dcvKLSlH2aOxyOtsu4A6PVKeYLYmUUyH yCveWETbr1mN/Xn22Qz0kK3cx56L/YLUhwiPo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=ZMQBUaHvtk1vIQA+hc3tpmJFo+bxlvko+gX68MeCUaYyO7erJyI8nI+MtNapiOd7TN KHicWA5J6qjVqdV5nMeL6xpsA/w7qRlWVnDqmpcPNeX7dddO746n+5b3paXLCIhPiqDi DXbOvqyCsSMtDTLVgWNtLBZbDmqGe02j8YOGQ= MIME-Version: 1.0 Received: by 10.223.5.156 with SMTP id 28mr6380025fav.74.1268747237343; Tue, 16 Mar 2010 06:47:17 -0700 (PDT) Reply-To: RQuadling@googlemail.com In-Reply-To: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> References: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> Date: Tue, 16 Mar 2010 13:46:57 +0000 Message-ID: <10845a341003160646g39687b31nec6627a5d5ea41f7@mail.gmail.com> 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: rquadling@googlemail.com (Richard Quadling) On 16 March 2010 13:30, Felix De Vliegher wrot= e: > 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 > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > Maybe not as efficient as it could be but ... 'Itchy', 'Two' =3D> 'Knee', 'Three' =3D> 'San', 'Four' =3D> 'She'); echo @reset(array_keys(array_values($input), 'Knee')); Richard. --=20 ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474= 731 ZOPA : http://uk.zopa.com/member/RQuadling