PHP array shorthand changes: splice?
| From: | Justin Rovang | Date: | Mon, 18 Jul 2011 16:08:39 +0000 |
| Subject: | PHP array shorthand changes: splice? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-54044@lists.php.net to get a copy of this message | ||
I've sifted through the RFC for the array shorthand changes which are quite nice. Something I'm sure has been brought up, but possibly not recently: shorthand array splice. Has there been any notion to the introduction of this feature in the future?
The reason I bring this up is it seems that the proposed notation that uses a colon may eliminate, or complicate the introduction of this in the future.
Most languages that support this always start with the start index, and either specify the length of splice, or the last element to splice to.
e.g.:
$array = [0: 'PHP', 1: 'internals', 2: 'mailing list'];
/* Then a possible splice approach: */
$temp = $array[0 : 2];
$temp = $array[0, 2];
Now, this could be I simply don't know the behavior of the new syntax when used on top of an existing array, (Does $array[0=>'Test]; even do anything in terms of assignement?)