Re: Support negative indexes for arrays and strings
| From: | slevy1 at pipeline dot com | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: Support negative indexes for arrays and strings | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-62642@lists.php.net to get a copy of this message | ||
The idea was originally proposed by Marc Easen who created a patch and asked for help with putting
together an RFC. I have yet to see a formal proposal but on the list Easen modified his idea so
that it should apply to strings alone. With that in mind, would it really cause problems to have
code like this:
$string = "Roses are red";
$string[-3] = "R"; // modifying $string[10]
echo $string; // Roses are Red
The negative indexing provides a pleasurable way to easily access part of a string; it's simple
and should be fast, too.
I think Easen's proposal is laudatory and I for one would like to see it happen for PHP and
provide users with more ease and satisfaction in working with the language.
SL