On 2012-08-16 08:27, Nikita Popov wrote:
On Wed, Aug 15, 2012 at 10:22 PM, Stas Malyshev <smalys...@sugarcrm.com> wrote:
Hi!

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:

I see:
if(($key = array_search($del_val, $messages)) !== false) {
     unset($messages[$key]);
}

Nothing horrible here.

Btw, deleting all values (not just the first) is also very easy currently:

foreach (array_keys($array, $delValue) as $key) {
     unset($array[$key]);
}

$array = array_diff($array, [$delValue]);



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to