I have a PHP array as follows:
$messages = [312, 401, 1599, 3, ...];
I want to delete the element containing the value $del_val
$del_val
With PHP 7.4 using arrow functions:
$messages = array_filter($messages, fn ($m) => $m != $del_val);
To keep it a non-associative array wrap it with array_values():
array_values()
$messages = array_values(array_filter($messages, fn ($m) => $m != $del_val));