>
> $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.



On 20 March 2015 at 13:04, Rowan Collins <rowan.coll...@gmail.com> wrote:

> Alex Bowers wrote on 20/03/2015 12:32:
>
>> We also need to consider then the possibility of setting data by position.
>>
>> What should $array[@1:3]  = [1,2,3] do?
>>
>> Should it overwrite the values there, and append any that don't exist, or
>> should it be a parse error?
>>
>>
> Good catch. I guess it could delete the range and replace with the new
> value, regardless of size - then you could remove elements from an array
> with it, too:
>
> $array[@1:3] = []; // Remove the second through fourth element
> $array['x':'z'] = []; // Remove all elements with keys between 'x' and
> 'z', inclusive
>
> Not sure how that compares to other languages with similar syntax.
>
> It would be kind of cool if it applied to string subscripts as well:
>
> $version = 'PHP 5.6.1';
> $version{4:} = '7!';
> echo $version; // 'PHP 7!'
>
> Regards,
> --
> Rowan Collins
> [IMSoP]
>

Reply via email to