快速将Array里的NULL, FALSE以及空字符去掉,但同时保留0值,可以用array_filter,以”strlen” 为callback

$result = array_filter( $array, 'strlen' );

如果只需要将Array里的NULL去掉,保留FALSE以及0值,可以用array_filter,以”is_not_null” 为callback

$result = array_filter( $array, 'is_not_null' );

Advertisements
Posted in PHP

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s