I have a PHP array as follows:
$messages = [312, 401, 1599, 3, ...];
I want to delete the element containing the value $del_val
If you don't know its key it means it doesn't matter.
You could place the value as the key, it means it will instantly find the value. Better than using searching in all elements over and over again.
$messages=array();
$messages[312] = 312;
$messages[401] = 401;
$messages[1599] = 1599;
$messages[3] = 3;
unset($messages[3]); // no search needed