On 12 January 2013 16:41, Ben Ramsey <ram...@php.net> wrote:
>
> I must have misread the Git Workflow page of the wiki, which states:
>
> "A patch will be applied to the oldest possible branch. If the Release
> Manager of 5.3 accepts the change, commit it to the 5.3 branch. We will use
> regular merging between the release branches."
>
> I can submit a new pull request against the master branch, if that's
> acceptable. This is intended for 5.5.
>

The wiki is a little unclear there. The "oldest possible branch"
against which this can be applied is, theoretically, PHP 5.5 according
to the release process that was agreed to. In all likelihood, it could
be added to 5.4 with the RMs consent. So the "oldest possible branch"
is going to be one of those, not 5.3 nor master.

One extra little detail that would be handy (at least for my own
considered use of this new function) would be able to utilise the
existing keys of the target array rather than relying on new 0-indexed
keys or values from sub-arrays.

$array = [
    123 => ['Chuck', 'Norris'],
    310 => ['Sylvester', 'Stallone'],
    736 => ['Jason', 'Statham']
];

$first_names = array_column($array, 0, true); // 3rd param used as
"preserve keys" (default = false)
// [123 => 'Chuck', 310 => 'Sylvester', 736 => 'Jason']

The above is not really an issue, given array_keys() and
array_combine() [though one neat function call would be nice], but it
becomes most useful when the resulting array has fewer values than the
original. To take your example from the RFC:

$mismatchedColumns = array(
    array(
        'a' => 'foo',
        'b' => 'bar',
        'e' => 'baz'
    ),
    array(
        'a' => 'qux',
        'c' => 'quux',
        'd' => 'corge'
    ),
    array(
        'a' => 'grault',
        'b' => 'garply',
        'e' => 'waldo'
    ),
);

$b = array_column($mismatchedColumns, 'b', true); // 3rd param used as
"preserve keys" (default = false)
// [0 => 'bar', 2 => 'garply']

Note how that has keys [0, 2].

So the idea is to potentially change the $indexKey parameter from
string|int to bool|string|int where:
- false => same as null or not using the argument: uses 0-based keys
(as RFC currently does)
- true => uses keys from $input (suggested addition)
- int|string => uses sub-array's $indexKey'th value as key (or 0-based
for missing value, as RFC currently does)

Thoughts?

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

Reply via email to