Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47303 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95558 invoked from network); 16 Mar 2010 13:31:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2010 13:31:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=felix.devliegher@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=felix.devliegher@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: felix.devliegher@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-ww0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:49135] helo=mail-ww0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/EC-15129-7188F9B4 for ; Tue, 16 Mar 2010 08:31:04 -0500 Received: by wwd20 with SMTP id 20so320713wwd.29 for ; Tue, 16 Mar 2010 06:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:content-type:subject :date:message-id:to:mime-version:x-mailer; bh=vcRBVSti0HhABKL6MWoAZTOejSWXFlr4JbF9ntS5wuQ=; b=sjAc5VZzuRyGtEqYzda6WTuvkn67shg520X+c8hKAn1EmR9kxhrFJDAF4TR0ep5Fth WxC59H3DDN2tTF+0jDw6aTpOhX0SPSDDmDqBodbbVpdhus8Byk/m5GEHcsVQmHH3Vuvq BKkJHw9SN7jQI0bOB8do5tP5/hkXS+yFC1PFQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:subject:date:message-id:to:mime-version:x-mailer; b=AONHUnja+BHfFtPKFSqY/5tJDhYZ1QSgATyHL3B1719lweCawi1/Kigh9TU9KqxvZQ jPsBagq7F/w0OqPpCLq/ikyD0xBohntCMXX6drebrQj9wMOB1p/hXyNVwminI6a44WZi 5ZtfyoCFzSBLpszYYl0YeDu80SV+4bAADI5Ro= Received: by 10.216.89.80 with SMTP id b58mr695260wef.73.1268746260825; Tue, 16 Mar 2010 06:31:00 -0700 (PDT) Received: from [10.0.1.102] (cable-175-208.zeelandnet.nl [82.176.175.208]) by mx.google.com with ESMTPS id m5sm1449633gve.25.2010.03.16.06.30.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 16 Mar 2010 06:30:49 -0700 (PDT) Content-Type: multipart/mixed; boundary=Apple-Mail-22-528755296 Date: Tue, 16 Mar 2010 14:30:47 +0100 Message-ID: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> To: PHP internals Mime-Version: 1.0 (Apple Message framework v1077) X-Mailer: Apple Mail (2.1077) Subject: array_seek function From: felix.devliegher@gmail.com (Felix De Vliegher) --Apple-Mail-22-528755296 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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 = =3D 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 =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 = 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 --Apple-Mail-22-528755296--