Remove NULL values only

$new_array_without_nulls = array_filter($array_with_nulls, 'strlen');

Remove any FALSE values

This includes NULL values, EMPTY arrays, etc. Thanks to Paul Scott for pointing out this method.

$new_array_without_nulls = array_filter($array_with_nulls);

Leave a comment