First, I'd like to announce the native implementation is available on
github:
https://github.com/cataphract/php-src/compare/array_part
Please review this feature BEFORE voting starts. Unless something comes up
that has to be dealt with until then, I want to start voting on Monday,
28th May.
Now my answer to Richard:
On Mon, 21 May 2012 21:30:24 +0200, Richard Lynch <c...@l-i-e.com> wrote:
On Mon, May 14, 2012 9:03 am, Gustavo Lopes wrote:
* array_slice() can preserve keys, array_part() cannot because when
collapsing levels this would mean the possibility of overwriting
elements.
A predictable LIFO or FIFO for any collapsed keys would be reasonable,
and probably not much more work to implement.
By LIFO I mean that the last value to be put under a key would "win" I
think that would be the most natural.
Such a behavior would be possible and would not be difficult to implement.
However, it raises questions that are not easy to answer like:
- should it keep the first or the last keys? Or perhaps it could instead
collect all the elements under a new array.
- should the behavior for numeric keys differ from that of string keys
(perhaps in a array_merge way?)
Since the path to add this behavior in the future is straightforward (add
another optional argument, like in array_slice), not including it causes
little damage in terms of future growth.
On the other hand, my hope is that limiting the current design decisions
to a easy subset may allow this to be merged rapidly.
--
Gustavo Lopes
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php