Re: PR 287 - added use_keys argument to array_filter() [Discussion]
| From: | Tjerk Meesters | Date: | Thu, 26 Sep 2013 22:51:25 +0000 |
| Subject: | Re: PR 287 - added use_keys argument to array_filter() [Discussion] | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-69361@lists.php.net to get a copy of this message | ||
Hi,
On 27 Sep, 2013, at 12:31 AM, Andrea Faulds <ajf@ajf.me> wrote:
> On 26/09/2013 05:42, Tjerk Meesters wrote:
>> Hi,
>>
>> I've updated my patch to allow a range of values to be passed as the third
>> argument: pass key, pass value or pass both.
>>
>> Instead of using OR-able constants, I went with an enumeration type because
>> there are only going to be three options; it just felt wrong to have
>>
ARRAY_FILTER_USE_KEY | ARRAY_FILTER_USE_VALUE instead of a
>> simpler
>> ARRAY_FILTER_USE_BOTH or even just
>> true.
>
> I suggest the following change:
>
> ext/standard/php_array.h:119:
> > #define ARRAY_FILTER_USE_BOTH 1
> > #define ARRAY_FILTER_USE_KEY 2
> > #define ARRAY_FILTER_USE_VALUE 3
>
> becomes:
>
> ext/standard/php_array.h:119:
> > #define ARRAY_FILTER_USE_KEY 1
> > #define ARRAY_FILTER_USE_VALUE 2
> > #define ARRAY_FILTER_USE_BOTH 3
>
> Such that we have the best of both worlds, either
> ARRAY_FILTER_USE_BOTH or ARRAY_FILTER_USE_KEY |
> ARRAY_FILTER_USE_VALUE :D
I deliberately chose these values so that I can simply specify true to mean pass both
values. Bit masks seem cumbersome in this situation.
>
> --
> Andrea Faulds
> http://ajf.me/
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>