Re: RFC - Array slice syntactic sugar
| From: | Stanislav Malyshev | Date: | Fri, 20 Mar 2015 23:03:22 +0000 |
| Subject: | Re: RFC - Array slice syntactic sugar | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85348@lists.php.net to get a copy of this message | ||
Hi!
> This may be not so easy to implement - imagine passing $array[*1:4] by
> reference.
>
>
> This would be the same as doing
> $array[array_keys($old_array)[1]] = $new_array[0];
> $array[array_keys($old_array)[2]] = $new_array[1];
> $array[array_keys($old_array)[3]] = $new_array[2];
> $array[array_keys($old_array)[4]] = $new_array[3];
I don't think you understood what I am saying. Lvalues in PHP can be
used not only in assignment context, but also in passing-by-ref context,
and in that case I have no idea how you pass $array[*1:4] by reference -
what is actually passed?
> There is the array_splice method that can do the same thing, however
> this to me is less obvious as to what is happening:
I don't see any reason why it would be less obvious, if you bother to
look at man page of array_splice once.
--
Stas Malyshev
smalyshev@gmail.com