吴伟贤のBlog

Feed Rss

php 删除数组中值为空的项?

12.22.2011, php, by .

一直以来没有不知道array_filter这个函数有这个功能.网上找到的方法

$arr=array( ‘0’=> ‘a’, ‘1’=> ”, ‘2’=> ‘b’);
$arr = array_filter($arr, create_function( ‘$v’, ‘return !empty($v);’));
print_r( $arr );

评论已关闭。