Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-31 Thread Colin O'Dell
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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-30 Thread Colin O'Dell
> > 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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-30 Thread Marco Pivetta
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: >

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-30 Thread Marco Pivetta
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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-30 Thread Nikita Popov
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: >

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Colin O'Dell
> > 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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Côme Chilliet
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: >

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Colin O'Dell
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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Marco Pivetta
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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Colin O'Dell
> > 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 >

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Colin O'Dell
> > 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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Andreas Heigl
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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Thomas Nunninger
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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Colin O'Dell
> > 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

Re: [PHP-DEV] [RFC Discussion] array_change_keys()

2016-05-29 Thread Fleshgrinder
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