Re: xarray - The missing array functions you are looking for, implemented in Extension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 16 October 2015 09:59:30 BST, Peter West <pbw@xxxxxxxxx> wrote:
>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

Peter, this has been brought up before, and for the sake of everyone please don't derail this thread. Long story short, it's part of the rules of posting, makes it easier to read on email and the web digest, and that attitude is the quickest way to put people off of helping you on the list when you need it.

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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux