Re: RFC - Array slice syntactic sugar

From: Date: Fri, 20 Mar 2015 13:21:07 +0000
Subject: Re: RFC - Array slice syntactic sugar
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-85288@lists.php.net to get a copy of this message
Alex Bowers wrote on 20/03/2015 13:10:
    $array['x':'z'] = []; // Remove all elements with keys between 'x'
    and 'z', inclusive
I believe i mentioned in the past about strings not being allowed for ranges, since there is no real way to check this (and this appears to be by key not by index) which should be a separate RFC thread, assuming this one gets accepted to be expanded upon.
I'm carrying over my syntax from previous examples - [a:b] meaning a key-based slice (which implies accepting string keys, because there's no reason not to) vs [@a:b] meaning a positional slice. See my earlier mail on the 6 different types of access - I do realise you're not planning to implement them all, just playing with the implications of different decisions if we carry them through consistently in the future. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#85288) next »