Re: On arrays starting with a negative index
| From: | Pedro Magalhães | Date: | Wed, 01 Mar 2017 20:46:18 +0000 |
| Subject: | Re: On arrays starting with a negative index | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98372@lists.php.net to get a copy of this message | ||
On Wed, Feb 15, 2017 at 7:28 PM, Pedro Magalhães <mail@pmmaga.net> wrote:
> Hi internals,
>
> I've prepared a PR (https://github.com/php/php-src/pull/2383) that would
> change the current behavior of arrays when the first index is a negative
> integer.
>
> The main goal is to make the result of array_fill more in line with what
> you would expect if the start_index is a negative integer. However, the
> current (and historical) result is properly documented on the array_fill
> page.
>
> I would like to hear your feedback about this change and if you feel this
> warrants an RFC.
>
> Best regards,
> Pedro Magalhães
>
Bump on this topic as I would like to hear some feedback.
As a clarification, the current implementation of the PR affects arrays in
general, not only array_fill. Any array that starts with a negative index
would continue from that index instead of 0. Meaning that [-2 => true,
true, true] would now return [-2 => true, -1 => true, 0 => true] instead of
[-2 => true, 0 => true, 1 => true].
Regards,
Pedro