Re: Support negative indexes for arrays and strings

From: Date: Fri, 14 Jan 2011 18:47:41 +0000
Subject: Re: Support negative indexes for arrays and strings
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-51271@lists.php.net to get a copy of this message
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

« previous php.internals (#51271) next »