php 删除数组元素_PHP教程

WBOY
Release: 2016-07-21 15:48:01
Original
1199 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;
}
}
}
}

www.bkjia.com true http://www.bkjia.com/PHPjc/319816.html TechArticle 如果没有提供 callback 函数,array_filter() 将删除 input 中所有等值为 FALSE 的条目。 删除数组中为空值的元素就可以使用这个函数。 复制代码...
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!