Re: re: removing an item from an array
| From: | Yasuo Ohgaki | Date: | Tue, 21 Aug 2012 19:13:09 +0000 |
| Subject: | Re: re: removing an item from an array | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62350@lists.php.net to get a copy of this message | ||
Hi
2012/8/22 Levi Morrison <morrison.levi@gmail.com>:
> On Tue, Aug 21, 2012 at 12:53 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
>> 2012/8/21 Levi Morrison <morrison.levi@gmail.com>:
>>>
>>> I'm against this RFC, but if you are going to even try to add
>>> something, please keep it consistent! Don't modify
>>>
array_delete to
>>> take a callable, instead make a different function
>>> array_udelete or
>>> something.
>>>
>>
>> Original proposal is adding array_delete() and this is under discussion.
>> We don't have to add array_add()
>>
>>> And keep default $strict values consistent with existing functions
>>> that have that parameter.
>>
>> Users should use array_walk() when they would like to delete element(s).
>> To be consistent, it should be callable.
>>
>> Regards,
>>
>> --
>> Yasuo Ohgaki
>> yohgaki@ohgaki.net
>
> I didn't say anything about array_add. I meant to say if
> you are
> going to try to add something to the core that you need to be
> consistent with the other array functions.
>
> Why use array_walk to delete elements? Isn't the whole
> point of
> array_delete to make that process easier?
>
The reason why use array_walk is this is the best way to delete
elements with PHP.
From the Stack Overflow's page (and this thread), we can tell the
problem is lack of intuitive API for array element deletion.
> I think you missed the whole point of my last message: keep the
> functions you propose similar to ones that already exist.
That's my point, too.
array_walk() is there from PHP3 at least, IIRC.
array_delete() is easier to use, too. i.e. No "use (&$array)" for closure
and counter variable when user would like to know how many elements
were deleted.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net