Please DO top-post, as it makes it much easier to determine whether a new message is relevant. This becomes more evident the longer a thread goes on. Please abandon this dogmatism, in favour of empirical practicality. Peter West “I am the vine, you are the branches.” > On 16 Oct 2015, at 6:31 pm, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote: > > > > On 16 October 2015 08:58:55 BST, Lin Yo-an <cornelius.howl@xxxxxxxxx> wrote: >> New function added to xarray extension: >> >> $array = [ >> "created_at" => ... >> "updated_at" => .... >> ]; >> array_keys_replace($array, [ >> "_at" => "_on", >> ]); >> >> >> >>> On Oct 15, 2015, at 12:40, Lin Yo-an <cornelius.howl@xxxxxxxxx> >> wrote: >>> >>> On Oct 15, 2015, at 06:44, Ryan Pallas <derokorian@xxxxxxxxx> wrote: >>>> >>>> array_pluck is in the language, called array_column >>> >>> array_pluck is designed to support dot expression, for example: >>> >>> array_pluck($array, "parent.child.child1.attr"); >>> >>>> array_remove is just array_filter, why do I need another function >> for that? >>> >>> array_filter only passes value to the callback. in PHP 5.6, there is >> a new option to pass both key and value, >>> however PHP 5.5 doesn't have this option. >>> >>> Implementing this function in extension make it possible. >>> >>>> array_add - why do I need the overhead of a function call, when I >> can do $a[ >>>> *key*] = *value* >>> >>> The reason has been described in the document: array_add only adds >> data when the key doesn't exist. >>> >>> You can treat it as a set operation. >>> >>> $array = [ ]; >>> array_add($array, "key", 10); // key => 10, return true >>> array_add($array, "key", 20); // key => 10 still, return false >>> >>>> array_build - this seems neat, but I think it needs a better >> example, I can >>>> do the example already with array_combine(array_column(), >> array_column()) >>> >>> By using array_build, you can pass complex structure as the new >> value, or adding complex logic in the callback. >>> >>>> array_each - this is just a foreach with an isolated scope and >> function >>>> overhead on every iteration, why would I want that? >>> >>> Yeah I have to admit it's pretty much similar, however sometimes you >> want to pass a iteration handler from external, >>> and array_map returns a new array, array_each is faster than >> array_map because it's much lightweight and it doesn't return value. >>> >>>> array_keys_join - while I like this, why doesn't it have the same >> argument >>>> order as implode/join (glue, array)? >>> >>> The reason I put array as the first argument is, consistency. and >> actually the "glue" is optional, so you can simply ignore the argument. >>> >>> $key = array_keys_join($array); >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php > > Please can you try to not top post, it really makes it more difficult to read the thread, and the rules do state that replies should be inline quoted or bottom posted > > Thanks > Ash > -- > Sent from my Android device with K-9 Mail. Please excuse my brevity. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php