Home > php教程 > php手册 > body text

php 删除数组元素

WBOY
Release: 2016-06-13 12:25:00
Original
858 people have browsed it

如果没有提供 callback 函数,array_filter() 将删除 input 中所有等值为 FALSE 的条目。
删除数组中为空值的元素就可以使用这个函数。

复制代码 代码如下:


//删除数组中的一个元素
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;
}
}
}
}

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template