Re: [PHP-DEV] Proposal for new array_map function to pass in keys

2013-06-08 Thread Sherif Ramadan
On Sat, Jun 8, 2013 at 3:13 AM, Pierre du Plessis wrote: > > function my_call_back($key, $value) { >> return array($value, strlen($value)); >> } >> $array = str_word_count("PHP is lots of fun!"); >> $array = array_map_key('my_call_back', $array); >> >> >> The result would be the following arra

Re: [PHP-DEV] Proposal for new array_map function to pass in keys

2013-06-08 Thread Pierre du Plessis
> function my_call_back($key, $value) { > return array($value, strlen($value)); > } > $array = str_word_count("PHP is lots of fun!"); > $array = array_map_key('my_call_back', $array); > > > The result would be the following array: > > array(5) { > ["PHP"]=> > int(3) > ["is"]=> > int(2)

[PHP-DEV] Proposal for new array_map function to pass in keys

2013-06-07 Thread Sherif Ramadan
I'm proposing a new function similar to the implementation of array_map that allows us to apply a user-supplied callback to every element in the array with the addition of the callback being passed the key as well as the value of each element. Additionally, I would like to propose that the callback