Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61224 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54209 invoked from network); 14 Jul 2012 10:34:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2012 10:34:28 -0000 Authentication-Results: pb1.pair.com header.from=dragoonis@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dragoonis@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.170 as permitted sender) X-PHP-List-Original-Sender: dragoonis@gmail.com X-Host-Fingerprint: 209.85.213.170 mail-yx0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:37628] helo=mail-yx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 10/6A-20866-33B41005 for ; Sat, 14 Jul 2012 06:34:28 -0400 Received: by yenl12 with SMTP id l12so5011324yen.29 for ; Sat, 14 Jul 2012 03:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=BQHD8zRcM+vGkjLSo4i4Zq3Yjquhqn9KoydgdoY+nqc=; b=ddC6B7jDiOWXoDenKmhziQMp+nhQcJubkrUATvq2TTUDis/zFd+B/fIikxSpvH3+la OojnYUiKpuireuKQ/qi0eCgySzuNLtP0isjmEyN0MvYry7LnJ2I9T+QnYH+eY9YwHwro uF/1CFxoGlQWYiy7lJy67YtxERPVf95GXAO6YBAb9QC7QYF0CS73KWrRvt4gWv0eeJap IA9G3I5M6Kb5Zu1YkMRC0r7UhMAH8LzkciW2wtlbgaz4Y4X1/a5DHZkTVs+KhVhjqAgE fxs2FdkLTliS+RyaC3BXtvygfmpcV6gLNYUgXiDkJH8taxKBhv7I7YzyYREKDlsoKAn/ 8Y4A== MIME-Version: 1.0 Received: by 10.50.194.194 with SMTP id hy2mr1202406igc.56.1342262064589; Sat, 14 Jul 2012 03:34:24 -0700 (PDT) Received: by 10.64.32.72 with HTTP; Sat, 14 Jul 2012 03:34:24 -0700 (PDT) In-Reply-To: References: <5000BF44.3080907@sugarcrm.com> Date: Sat, 14 Jul 2012 11:34:24 +0100 Message-ID: To: Anthony Ferrara Cc: Stas Malyshev , Brandon Wamboldt , Andrew Faulds , internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Re: array_last_key() function From: dragoonis@gmail.com (Paul Dragoonis) On Sat, Jul 14, 2012 at 3:04 AM, Anthony Ferrara wrote: > Stas, > >> I like this idea. array_first_key would be nice too >> >> I am probably missing something, but what those would allow to do that >> rewind/end+key() doesn't do? >> > > The big thing that it does that end()+key() doesn't do is really what it > doesn't do (update the internal pointer). > > end() modifies the array pointer. So if you try this in user-land: > > function array_last_key(array $array) { > end($array); > return key($array); > } > > It will always force a full copy of the array (at least the hash table). > Implementing this as a core function however would eliminate that one > side-effect... and it beats doing $var = null; if(isset($array[0])) { $var = $array[0]; }