Hi!

> To be the same, your example would have to be:
> 
> // alternative old
>   foreach(array_slice($results, 0, 9, true) as $result) {
>       echo $result . "\n"; // 1 2 3 4 5 6 7 8 9
>   }
>  
> since this will preserve the array keys.

You're not using the keys in foreach, so why you need to preserve them?

> $array[*1:4] = [1,2,3,4]; // Sets array items 1 through 4 to be the
> values (and keys if provided), of the array assigned.

This may be not so easy to implement - imagine passing $array[*1:4] by
reference. You should be able to do so, since $array[*1:4] is an lvalue
for you, but what would you pass? What if $array changes in the
meantime? There's a big can of worms here. And you already have
array_splice which doesn't have these issues.

-- 
Stas Malyshev
smalys...@gmail.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to