Is there an easy way to delete an element from an array using PHP, such that foreach ($array) no longer includes that element?
foreach ($array)
I thought that setting it
For associative arrays, with non-integer keys:
Simply, unset($array[$key]) would work.
unset($array[$key])
For arrays having integer keys and if you want to maintain your keys:
$array = [ 'mango', 'red', 'orange', 'grapes'];
unset($array[2]); $array = array_values($array);
array_splice($array, 2, 1);