array_filter()函数根据回调函数过滤数组中的值,如果省略回调函数,则默认过滤空值。语法:array_filter(array[,function])例子:$array=['管理综合项目','','2021年7月6日','','','过滤空值'];//输出过滤结果print_r(array_filter($array));Array('管理综合项目','2021年7月6日','过滤空元素')使用回调函数过滤指定值示例:$array=[1,2,3,4,5,6,7,8];//大于5的元素print_r(array_filter($array,function($item){return$item>5;);Array(6,7,8)
