Re: re: removing an item from an array

From: Date: Tue, 21 Aug 2012 02:10:11 +0000
Subject: Re: re: removing an item from an array
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-62329@lists.php.net to get a copy of this message
Hi,

2012/8/21 Rasmus Schultz <rasmus@mindplay.dk>:
> I have a login (mindplay) but I do not have permission to post or edit
> anything on the wiki...

I've created RFC for this

https://wiki.php.net/rfc/array_delete

Get wiki account and finish discussion.
I may write patch for this with my spare time, but
it may take while to find time. I suggest write patch
and send pull request.

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

>
> On Mon, Aug 20, 2012 at 8:01 PM, Will Fitch <willfitch@php.net> wrote:
>
>> Please let this die until someone is serious enough to come up with an
>> rfc. This has been nothing but counterproductive arguing. If someone feels
>> strongly about it, write an rfc then we can discuss?
>> On Aug 20, 2012 7:53 PM, "Yasuo Ohgaki" <yohgaki@ohgaki.net> wrote:
>>
>>> Hi,
>>>
>>> 2012/8/21 Herman Radtke <hermanradtke@gmail.com>:
>>> >>> May be we should have something like
>>> >>
>>> >> >>
>>> >> >> array_delete_if($array, function($v, $k=null) { if ($v == 300)
>>> return
>>> >> >> true; })
>>> >> >
>>> >> > So array_filter?
>>> >>
>>> >> I'll use it or like for deleting, but the point of this thread is
>>> >> "intuitive function for deleting element(s)"
>>> >>
>>> >> array_delete($array, $value|callable)
>>> >>
>>> >> would be nicer for users, perhaps.
>>> >
>>> >
>>> > You are basically asking to alias array_filter with "array_delete".
>>> That is
>>> > a very slippery slope. I think array_filter is very a very obvious
>>> choice to
>>> > remove something from an array. The "filter" function/method is common
>>> in
>>> > functional languages (and functional frameworks like Underscore).
>>> >
>>> > These are things developers just need to learn as part of development.
>>> > Really, this is entire thread should be on stack overflow, not
>>> internals.
>>>
>>> I guess you haven't read later post.
>>>
>>> You've also made a novice mistake.
>>> array_filter() DO NOT delete elements, but creates new array.
>>> array_delete() is another form of array_walk(), not array_filter().
>>> See my posts.
>>>
>>> Having a API for dedicated task is good thing.
>>> Who would argue array_pop()/array_push() isn't needed?
>>>
>>> Regards,
>>>
>>> --
>>> Yasuo Ohgaki
>>> yohgaki@ohgaki.net
>>>
>>> --
>>> PHP Internals - PHP Runtime Development Mailing List
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>


Thread (91 messages)

« previous php.internals (#62329) next »