$colors = array("blue","green","red");
//delete element in array by value "green"
if (($key = array_search("green", $colors)) !== false) {
unset($colors[$key]);
}
<?php
$arr = array('Sam','Kin','Alex','Dineal');
if(in_array('Sam',$arr)){
unset($arr[array_search('Sam',$arr)]);
}
print_r($arr);
?>
Array
(
[1] => Kin
[2] => Alex
[3] => Dineal
)
if (($key = array_search($value, $sampleArray)) !== false) {
unset($sampleArray[$key]);
}
// matrix array
foreach($appsList as $key => $app) {
if($app["app_status"] !== "approved") {
// remove orange apps
unset($appsList[$key]);
}
}
if (($key = array_search($del_val, $messages)) !== false) {
unset($messages[$key]);
}