Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51271 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74606 invoked from network); 14 Jan 2011 18:47:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2011 18:47:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.133 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.133 smtp133.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.133] ([67.192.241.133:54268] helo=smtp133.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/05-48854-05A903D4 for ; Fri, 14 Jan 2011 13:47:46 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp23.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id D3BF82F8222; Fri, 14 Jan 2011 13:47:41 -0500 (EST) X-Virus-Scanned: OK Received: by smtp23.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 954EB2F822C; Fri, 14 Jan 2011 13:47:41 -0500 (EST) Message-ID: <4D309A4D.9020904@sugarcrm.com> Date: Fri, 14 Jan 2011 10:47:41 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: Marc Easen CC: "internals@lists.php.net" References: <496E551C-85F0-423E-89FA-2C5245808320@easen.co.uk> In-Reply-To: <496E551C-85F0-423E-89FA-2C5245808320@easen.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Support negative indexes for arrays and strings From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > I would like to open the discussion around the support of negative > indexes, as I feel a lot of developers will benefit from this > syntactical sugar. What you are looking for is implemented in array_slice(). Python has shortcuts for this thing, like a[1:-1], but PHP doesn't. If you wanted to RFC something here, I think the idea of $a[X:Y] with array_slice semantics could be doable. $a[-1:1] would be your case then. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227