re: removing an item from an array
| From: | Rasmus Schultz | Date: | Fri, 17 Aug 2012 21:21:12 +0000 |
| Subject: | re: removing an item from an array | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-62224@lists.php.net to get a copy of this message | ||
>
> if(($key = array_search($del_val, $messages)) !== false) {
> unset($messages[$key]);
> }
>
> Nothing horrible here.
>
I disagree - this is (or should be) a simple, atomic operation...
yet, you've got a function-call, an intermediary variable, a boolean test,
and an unset statement repeating the name of the array you're deleting from.
This should be a simple statement or function/method-call, and in most
other languages it would be...