Re: Re: Support negative indexes for arrays and strings
| From: | Stas Malyshev | Date: | Sun, 02 Sep 2012 01:35:49 +0000 |
| Subject: | Re: Re: Support negative indexes for arrays and strings | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62649@lists.php.net to get a copy of this message | ||
Hi!
> 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
I see how this may work for strings and simple vectors, but what about this:
$a = array(-1 => "foo", -2 => "bar"); echo $a[-1];
It should keep returning "foo", right? So then the question is - what
$array[-1] actually means? Right now I'm not sure I understand it. I
guess if somebody wrote an RFC on that it'd make understanding it
easier. I see that the patch seems to address just the string part - but
the subject also mentions arrays. I think making it clear would be helpful.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227