Home > Backend Development > PHP Tutorial > 一上代码怎么理解?array_filter

一上代码怎么理解?array_filter

WBOY
Release: 2016-06-13 13:19:13
Original
1007 people have browsed it

请教高手 一下代码如何理解?array_filter
 $arr=array(0,0,0,1,2,4,2);
 $arr=array_filter($arr);
 print_r($arr);
?>
不是需要array_filter(array,function) ? 直接写数组是不是意思是自定义函数值为零?还是怎么理解?求指教

------解决方案--------------------
array array_filter ( array [, callback callback] ) 

array_filter() 依次将 array 数组中的每个值传递到 callback 函数。如果 callback 函数返回 TRUE,则 array 数组的当前值会被包含在返回的结果数组中。数组的键名保留不变。 

如果没有提供 callback 函数,array_filter() 将删除 array 中所有等值为 FALSE 的条目.
等值为false即是空,false,0.......
------解决方案--------------------
flase false false true true true true

Related labels:
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