Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61230 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77405 invoked from network); 14 Jul 2012 17:29:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2012 17:29:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.160.42 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:51421] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 00/9D-20866-E6CA1005 for ; Sat, 14 Jul 2012 13:29:19 -0400 Received: by pbbrp12 with SMTP id rp12so8280501pbb.29 for ; Sat, 14 Jul 2012 10:29:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding:x-gm-message-state; bh=93nANUevlNtv3ilo8K/n6JYQhCHtkJyXhrkC0kq+zXA=; b=ZhGQV76Rlzucv742kz/L3ZtyCUiqw7544HDgGSRbVRgZL/9fWJAFIcL5+cS3Hl5qNr s48zktOQrCujLlW7lMuho0nEwZXI6XVK/R+83sWPxK/goPnrHOG1llCApJ6VXFonsv/N J6n+d5+5W6MeWIwt8lQH5vOL1J3mzbg0XR2GWt2bYkRAHjte/epcFipvE7jJZPMdG0yA 3k1CKXhFH8O7CyD8ckmtHJJopKQxRWoPjv7UGPDnuUHn1DPI1iNW8fYSymYSaE7fQeqO UzZf4CyCy/svhf1dUEy6N7YYE7v1+Ex8URUG3t/vWUTc3t/Z0yB6eNv9DW1COlM4MQI5 bxQw== Received: by 10.66.81.232 with SMTP id d8mr10405894pay.66.1342286955582; Sat, 14 Jul 2012 10:29:15 -0700 (PDT) Received: from [192.168.200.5] (c-50-131-44-225.hsd1.ca.comcast.net. [50.131.44.225]) by mx.google.com with ESMTPS id ru4sm8369621pbc.66.2012.07.14.10.29.11 (version=SSLv3 cipher=OTHER); Sat, 14 Jul 2012 10:29:14 -0700 (PDT) Message-ID: <5001AC64.7040304@lerdorf.com> Date: Sat, 14 Jul 2012 10:29:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Anthony Ferrara CC: Gustavo Lopes , Stas Malyshev , Brandon Wamboldt , Andrew Faulds , internals References: <5000BF44.3080907@sugarcrm.com> In-Reply-To: X-Enigmail-Version: 1.4.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQlpW8sw3FDT0nwCOvSU7gECuMcfW0cKBavjVb8GUXWXWrwOVY53sonGOppVJ+dKAdW/ryCP Subject: Re: [PHP-DEV] Re: array_last_key() function From: rasmus@lerdorf.com (Rasmus Lerdorf) On 07/14/2012 10:13 AM, Anthony Ferrara wrote: > Gustavo, > > Why is the last key special? Why not a function to get the first or the >> penultimate key? >> > > How would such a function look? I think the function would look just like the function we have for doing this. key(array_slice($arr,-2)); And no, this has no side-effect of changing the array pointer in $arr, of course. And array_last_key() is identical to array_slice($arr,-1) is it not? The only thing array_last_key() saves is a single function call to key(). That doesn't seem worth it to me. -Rasmus