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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php