Re: Support negative indexes for arrays and strings

From: Date: Fri, 14 Jan 2011 18:34:43 +0000
Subject: Re: Support negative indexes for arrays and strings
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-51270@lists.php.net to get a copy of this message
> Hello everyone, > > 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. > > Example: > > echo $foo[2]; // 3 > echo $foo[-1]; // 3 Negative indexes are used already - for negative indexes. What should: $foo = array(1,2,3, -1 => 4, 5, 6); echo $foo[-1]; return? Now it returns 4. > > $bar = 'baz'; > echo $foo[2]; // 'z' > echo $foo[-1]; // 'z' > > The change to PHP is quite trivial, but as it's a change to language it needs to be > discussed. > > I'm happy to open a RFC, I have got a wiki account but I haven't got permission to > add a wiki page. Whom do I need to contact regarding getting correct permissions to add/edit wiki > pages?

« previous php.internals (#51270) next »