Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27335 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23303 invoked by uid 1010); 8 Jan 2007 13:19:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 23263 invoked from network); 8 Jan 2007 13:19:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jan 2007 13:19:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=info@adaniels.nl; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=info@adaniels.nl; sender-id=unknown Received-SPF: error (pb1.pair.com: domain adaniels.nl from 82.94.235.198 cause and error) X-PHP-List-Original-Sender: info@adaniels.nl X-Host-Fingerprint: 82.94.235.198 hyak.bean-it.nl Received: from [82.94.235.198] ([82.94.235.198:51760] helo=hyak.bean-it.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/8C-26124-49F32A54 for ; Mon, 08 Jan 2007 07:56:53 -0500 Received: from [127.0.0.1] (bean-it.xs4all.nl [213.84.27.165]) (authenticated bits=0) by hyak.bean-it.nl (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id l08CueTa019875 for ; Mon, 8 Jan 2007 13:56:43 +0100 Message-ID: <45A23F7B.2090808@adaniels.nl> Date: Mon, 08 Jan 2007 13:56:27 +0100 User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: PHP internals References: <76AD94BE-DD27-490D-88F8-8D0EC4A2C4E6@zort.net> <459F92A3.7040708@zend.com> In-Reply-To: <459F92A3.7040708@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Spam-Status: No, score=-0.7 required=4.0 tests=BAYES_20 autolearn=ham version=3.1.7 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on hyak.bean-it.nl Subject: Re: [PHP-DEV] [PATCH] New functions: array_key_index(), array_first(), array_last() From: info@adaniels.nl (Arnold Daniels) +1 Currently there is no way to get a key from an array without either moving the cursor or first getting all keys and go from there. While these function are easily written in PHP, the implementation feels more like a dirty workaround than a solid solution. I would personally use these functions and I think many others will as well, so they are worth being included. Arnold Antony Dovgal schreef: > On 01/05/2007 08:49 AM, John Bafford wrote: >> Hello, >> >> Attached is a patch and corresponding test file I would like to >> submit for inclusion in PHP. I would like this patch to be included >> in PHP 5.2.1, as it is entirely new code (and thus shouldn't cause >> regressions), but as RC2 was just released earlier today, I >> understand if it must wait until PHP 5.2.2. >> >> This patch implements three new functions, as described below. >> >> mixed array_key_index(array input, int index [, mixed value]) >> Return the array's index'th key (and optionally, value) >> >> mixed array_first(array input [, mixed value]) >> Return the array's first key (and optionally, value) >> This is equivalent to array_key_index($input, 0 [, $value]); >> >> mixed array_last(array input [, mixed value]) >> Return the array's last key (and optionally, value) >> This is equivalent to array_key_index($input, -1 [, $value]); > > -1 > Implementing these functions _in_ PHP can't take more than a minute. >