array_change_keys() has been added to 3v4l.org if anyone would like to try
it online. Simple example: https://3v4l.org/vehTo/rfc#tabs
>
> Ported to https://github.com/Ocramius/array_change_keys-benchmark, thanks!
>
I've updated the RFC's benchmarks based on your tool. They confirm that
array_change_keys is faster than array_combine but slower than foreach (in
most cases). Thanks for helping with this!
> No, but I really don'
On 30 May 2016 at 03:40, Colin O'Dell wrote:
> Marco,
>
>
>> 1. could you also provide the code for the benchmarks? I'd gladly
>> measure them with an accurate tool
>>
>
> Yeah that would be great! Here's the benchmark I was using:
> https://gist.github.com/colinodell/872c1f0c92351af687347c0c8b
I benchmarked this more carefully at
https://github.com/Ocramius/array_change_keys-benchmark - the results are
indeed not matching what is represented in the RFC.
Specifically, `array_change_keys` has performance that is comparable to
`array_combine` + `array_map`, and looping is still faster by a
On Mon, May 30, 2016 at 3:40 AM, Colin O'Dell wrote:
> Marco,
>
>
> > 1. could you also provide the code for the benchmarks? I'd gladly
> measure
> > them with an accurate tool
> >
>
> Yeah that would be great! Here's the benchmark I was using:
> https://gist.github.com/colinodell/872c1f0c92351
>
> Yes there is:
> array_combine(
> array_map($someFunc, array_keys($arr), $arr),
> $arr
> )
> This way $someFunc gets key as first argument and value as second. (you
> might use array_values($arr) instead of $arr but I’m not sure it’s worth it)
>
Good call! I have updated the RF
Le lundi 30 mai 2016, 01:40:21 Colin O'Dell a écrit :
> Marco,
>
>
> > 1. could you also provide the code for the benchmarks? I'd gladly measure
> > them with an accurate tool
> >
>
> Yeah that would be great! Here's the benchmark I was using:
> https://gist.github.com/colinodell/872c1f0c92351
Marco,
> 1. could you also provide the code for the benchmarks? I'd gladly measure
> them with an accurate tool
>
Yeah that would be great! Here's the benchmark I was using:
https://gist.github.com/colinodell/872c1f0c92351af687347c0c8be4f253
> 2. do we really need another array function tha
A bit skeptic here:
1. could you also provide the code for the benchmarks? I'd gladly measure
them with an accurate tool
2. do we really need another array function that is basically an
`array_combine(array_map($someFunc, array_keys($arr)), $arr)`?
3. and... do we really want another function t
>
> The RFC states "The new array returned by this function will contain the
> same values in the same order, but with potentially different keys."
>
> But further down it states, that on multiple times the same key the last
> one will "win". So in that special case it's **not** the same array
> an
>
> shouldn't it be possible to return null as new key? That way you say:
> Use the next free integer index.
>
> Not sure if returning null is wanted (as it could hide errors in the
> callback) or needed in some real world use cases. But it would be more
> in sync with $a[] = ...
>
That's an inter
Hi all.
Just one question for clarification:
The RFC states "The new array returned by this function will contain the
same values in the same order, but with potentially different keys."
But further down it states, that on multiple times the same key the last
one will "win". So in that special c
Hello,
shouldn't it be possible to return null as new key? That way you say:
Use the next free integer index.
Not sure if returning null is wanted (as it could hide errors in the
callback) or needed in some real world use cases. But it would be more
in sync with $a[] = ...
Regards
Thomas
>
> Does this RFC really require a 2/3 majority? I mean, it does not change
> the syntax or alters anything. It is just about a single new function?
>
> https://wiki.php.net/rfc/voting#required_majority
>
Good catch! You're right, this RFC only adds a single new function and
does not modify the s
On 5/29/2016 3:13 PM, Colin O'Dell wrote:
> I'd like to introduce a new RFC for your consideration and discussion:
> https://wiki.php.net/rfc/array_change_keys This would add a new function
> named array_change_keys() which simplifies the process of re-keying an
> array.
>
+1 from my side, the s
Hello everyone,
I'd like to introduce a new RFC for your consideration and discussion:
https://wiki.php.net/rfc/array_change_keys This would add a new function
named array_change_keys() which simplifies the process of re-keying an
array.
PHP currently has an array_change_key_case() method, but t
16 matches
Mail list logo