On 11/06/12 20:13, Stas Malyshev wrote:
Hi!

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?
The main question is what happens with "foo"[-4] or ['x'][-2].

And then one would expect some rather complex logic to compute -N for
$var[-N]
I don't see much of complex logic here, but $a[2] = 'a' would create a
new array element if it does not exist, while $a[-2] can't. Not a big
issue, but somewhat inconsistent I guess.


Please note I'm not referring the negative indexes in arrays, just strings. As I see strings as being simpler to implement and produce a greater benefit compared to supporting negative indexes for arrays. As arrays are more complex structures and adding this behaviour would complicate things somewhat.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to