1$colors = array("blue","green","red");
2
3//delete element in array by value "green"
4if (($key = array_search("green", $colors)) !== false) {
5 unset($colors[$key]);
6}
1//Delete array items with unset(no re-index) or array_splice(re-index)
2$colors = array("red","blue","green");
3unset($colors[1]);//remove second element, do not re-index array
4
5$colors = array("red","blue","green");
6array_splice($colors, 1, 1); //remove second element, re-index array
1//NO KEY supplied
2$message array("a", "b", "c", "d");
3$del_val = "b";
4if (($key = array_search($del_val, $messages)) !== false) {
5 unset($messages[$key]);
6}