Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60790 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13995 invoked from network); 11 Jun 2012 18:32:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jun 2012 18:32:49 -0000 Authentication-Results: pb1.pair.com header.from=ceo@l-i-e.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ceo@l-i-e.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain l-i-e.com designates 67.139.134.202 as permitted sender) X-PHP-List-Original-Sender: ceo@l-i-e.com X-Host-Fingerprint: 67.139.134.202 o2.hostbaby.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [67.139.134.202] ([67.139.134.202:1146] helo=o2.hostbaby.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/04-18025-0C936DF4 for ; Mon, 11 Jun 2012 14:32:33 -0400 Received: (qmail 77877 invoked by uid 98); 11 Jun 2012 18:34:21 -0000 Received: from localhost by o2.hostbaby.com (envelope-from , uid 1013) with qmail-scanner-2.05 ( Clear:RC:1(127.0.0.1):. Processed in 0.080905 secs); 11 Jun 2012 18:34:21 -0000 Received: from localhost (HELO www.l-i-e.com) (127.0.0.1) by localhost with SMTP; 11 Jun 2012 18:34:21 -0000 Received: from webmail (SquirrelMail authenticated user ceo@l-i-e.com) by www.l-i-e.com with HTTP; Mon, 11 Jun 2012 13:34:21 -0500 Message-ID: <131ff485e2f37a4388919f1c61fd4816.squirrel@www.l-i-e.com> In-Reply-To: <4FCD07CA.7030605@easen.co.uk> References: <496E551C-85F0-423E-89FA-2C5245808320@easen.co.uk> <4D309A4D.9020904@sugarcrm.com> <4FCD07CA.7030605@easen.co.uk> Date: Mon, 11 Jun 2012 13:34:21 -0500 To: "internals@lists.php.net" User-Agent: SquirrelMail/1.4.21 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [PHP-DEV] Support negative indexes for arrays and strings From: ceo@l-i-e.com ("Richard Lynch") On Mon, June 4, 2012 2:08 pm, Marc Easen wrote: > I have submitted a patch to support negative indexs in strings, as per > the conversation adding them to arrays could possibly detract from the > syntactical sugar they are indented to be. > > In summary: > > An alternative to: > $var = 'abc'; > echo $var[strlen($var) - 1]; > > Can be: > $var = 'abc'; > echo $var[-1]; This seems simple enough for a hard-coded -1, but... Would $var[-2] be strlen($var) - 2 and so on? And then one would expect some rather complex logic to compute -N for $var[-N] At that point, this becomes a pretty big WTF, imho. I've never honestly felt it to be a big burden to use strlen($var) - 1, so I don't really see the point, at least for me. -- brain cancer update: http://richardlynch.blogspot.com/search/label/brain%20tumor Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE