On Wed, Aug 15, 2012 at 10:22 PM, Stas Malyshev <smalyshev@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]);