Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47304 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97093 invoked from network); 16 Mar 2010 13:34:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2010 13:34:22 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:49144] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/3D-15129-CD88F9B4 for ; Tue, 16 Mar 2010 08:34:22 -0500 Received: by wyb36 with SMTP id 36so1362323wyb.29 for ; Tue, 16 Mar 2010 06:34:18 -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=jN4epy4B2JgtD3g8PZCR2QLXMUCpvLuK79pkGnANvtw=; b=VT8LO8BdW2EB4mlUv025UEf9QTvPyGmJ/gpbv2c4mJGxNFc/E9YI0V36jWk0BMpcR/ 7AomoSEAjam5oxHLYw/Qqh7dvEX9fyNvxNMYCQ2jeHjr1xL5ccN/rGMgl+aZt++QxpOi L3Q3Mx+Ft3e+XHZuG33MbxOZFdiq6xKPCJZXI= 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=qHlKrM/xbBu3VDQxkFFShuqu26l9+AAD9FYUQbbmUgOiOsmRUlScH3ZOyrED+bU7Wd 2WgDqWjJKMXwHvIT1Jsr9oaCPxzPMrZd6mxkTxPPBf5CdxNJ08rfvn7q5WzqY3rCJHTF 6d4k5kQ/wsux19oPh42YhavYneZSgR4+sRMmA= MIME-Version: 1.0 Received: by 10.216.86.193 with SMTP id w43mr711148wee.16.1268746458006; Tue, 16 Mar 2010 06:34:18 -0700 (PDT) In-Reply-To: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> References: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> Date: Tue, 16 Mar 2010 14:34:17 +0100 Message-ID: To: Felix De Vliegher Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] array_seek function From: pierre.php@gmail.com (Pierre Joye) hi Felix, Not sure about the usefulness of this function but the name is misleading (pls reattach the patch as .txt while being at it :). Does it set the position (_seek) or does it return the value of a given position (_get_pos)? or both (no idea :)? Cheers, Cheers, On Tue, Mar 16, 2010 at 2:30 PM, Felix De Vliegher wrote: > 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 > --=20 Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org