Home > Backend Development > PHP Tutorial > php delete array elements_PHP tutorial

php delete array elements_PHP tutorial

WBOY
Release: 2016-07-21 15:48:01
Original
1293 people have browsed it

If no callback function is provided, array_filter() will remove all entries in input whose value is FALSE.
You can use this function to delete null elements in the array.

Copy code The code is as follows:

//Delete an element in the array
function array_remove_value(&$arr, $var){
foreach ($arr as $key => $value) {
if (is_array($value)) {
array_remove_value($arr[$key], $var);
} else {
$value = trim($value);
if ($value == $var) {
unset($arr[$key]);
} else {
$arr[$key] = $value;
}
}
}
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319816.htmlTechArticleIf no callback function is provided, array_filter() will delete all entries in the input that have a value of FALSE. You can use this function to delete null elements from an array. Copy code...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template