Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: array_change_keys #1925

Closed
wants to merge 6 commits into from
Closed

Conversation

colinodell
Copy link
Contributor

colinodell and others added 6 commits May 27, 2016 23:04
The original methods used could result in arrays containing duplicate keys.
For example, if you ran this code:

    array_combine([1, 2, 3], function(){ return 'foo'; });

You'd have three array elements with the same keys! Didn't even know that was possible.
}

array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL_P(array)));
params = (zval *)safe_emalloc(2, sizeof(zval), 0);
Copy link
Member

@laruence laruence May 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the size is fixed, you could use stack allocated zval[2]

@smalyshev smalyshev added the RFC label Jun 14, 2016
@webdevxp
Copy link

webdevxp commented Jul 19, 2016

Should this function be named array_map_key() or array_map_keys() for consistency with other array key related functions?
And because I think it's actually a variant of array_map() that operates on keys instead of values.
But to do so, argument list should match array_map() too.

array_map_key( callable $callback , array $array1 [, array $... ] )

This also make it appear next to array_map() in PHP manual.

@cmb69
Copy link
Contributor

cmb69 commented Nov 27, 2018

What's the status here? The RFC is still listed as being under discussion – are there unresolved issues?

@colinodell
Copy link
Contributor Author

Sorry, I've been meaning to withdraw this RFC and replace it with a different implementation, but never got around to fleshing that alternative out. I'll close it for now and post to the mailing list. Thanks for the ping!

@colinodell colinodell closed this Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants