# PHP array shorthand changes: splice?

- Thread: https://externals.io/message/54044
- Original archive: https://news-web.php.net/php.internals/54044
- Started by Justin Rovang on 2011-07-18T16:08:39+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #54044 — Justin Rovang — 2011-07-18T16:08:39+00:00

URL: https://externals.io/message/54044#54044

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?)

---

## #54049 — Pierre Joye — 2011-07-18T16:42:35+00:00

URL: https://externals.io/message/54044#54049 · In reply to: #54044

hi.

On Mon, Jul 18, 2011 at 6:08 PM, Justin Rovang
<justin.rovang@minnesota.edu> wrote:
> 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.

The colon notation has been rejected.

Cheers,
-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
