You also have a function yourself. PHP tutorial. Many built-in functions have problems (not errors, but narrow applicability)
for(old array...){
if(is the value to be deleted)
Continue
$newArr[]=each value
}
return $newArr
Example
Array([0] => Hello[1] => world.[2] => It's[3] => a[4] => beautiful[5] => day.)
foreach($array as $k=>$v){
if($v == 'day'){
unset($array[$k]):
}
}
The efficiency of using foreach is not high, see PHP’s built-in functions
$arr = array("Hello","world","It's","beautiful","day");
Example 1
$arr = array_flip($arr);
unset($arr['world']);
$arr = array_flip($arr);
print_r($arr);
Example 2
The array_search() function is the same as in_array(), searching for a key value in the array. If the value is found, the key of the matching element is returned. If not found, returns false.
$arr = Array([0] => Hello[1] => world.[2] => It's[3] => a[4] => beautiful[5] => day.);
if(($key = array_search('day',$arr))){
unset($arr[$key]);
}
Example 3
The array_splice() function is similar to the array_slice() function, selecting a range of elements in an array, but instead of returning them, it deletes them and replaces them with other values.
if(($key = array_search('day',$arr))){
array_splice($arr, $key,1);
}