Re: removing an item from an array
| From: | Yasuo Ohgaki | Date: | Wed, 22 Aug 2012 01:45:59 +0000 |
| Subject: | Re: removing an item from an array | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62382@lists.php.net to get a copy of this message | ||
Hi,
2012/8/16 Rasmus Schultz <rasmus@mindplay.dk>:
> How come there is no straight-foward obvious way to simply remove a given
> value from an array?
>
> Just look at the number of horrible ways people solve this obvious problem:
>
>
> http://stackoverflow.com/questions/7225070/php-array-delete-by-value-not-key
>
> Shouldn't we have something simple, like:
>
> array_remove($array, $value) : array (returns a new array)
>
> and/or
>
> array_delete(&$array, $value) : bool (modifies array directly)
>
> ?
It was amazing that this thread has close to 90 mails.
I've added some use cases of array_udelete() to wiki, since
some people fails to see how it could be useful. I also bring
back to array_walk() version of equivalent example. I just
don't see any reason why we should replace it with slower
foreach() version.
I think the RFC page is almost complete.
https://wiki.php.net/rfc/array_delete
Any more comments?
--
Yasuo Ohgaki
yohgaki@ohgaki.net