Re: Re: Support negative indexes for arrays and strings

From: Date: Tue, 04 Sep 2012 14:47:14 +0000
Subject: Re: Re: Support negative indexes for arrays and strings
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-62798@lists.php.net to get a copy of this message
On Tue, Sep 4, 2012 at 6:31 PM, David Zülke <david.zuelke@bitextender.com>wrote: > On 03.09.2012, at 09:37, Jannik Zschiesche <hello@apfelbox.net> wrote: > > > The main problem arises from the ambiguity for $array[-1] for arrays. > > But this is easily solvable: just introduce a slice operator. > > > > $array[:-1] and the ambiguity is gone. > > That would return an array containing the last item as the sole member, > not the last item itself. > Assuming Python syntax, that returns the array of items up to (not including) the last item actually, an array containing the last item would be $array[-1:] - I wouldn't mind slice syntax :) nifty stuff ... maybe too nifty. > > David > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- -- Tjerk

« previous php.internals (#62798) next »