You are in a world of trouble now, because it is not too easy to distinguish null from 0 from false from "" from 0.0. But don't worry, it is solvable:
$result = array_filter( $array, 'strlen' );
Which is horrible by itself, but seems to work.
EDIT:
This is bad advice, because the trick leans on a strange corner case:
- strlen(0) will be strlen("0") -> 1, thus true
- strlen(NULL) will be strlen("")->0, thus false
- strlen("") will be strlen(("")->0, thus false
etc.
The way you should do it is something like this:
$my_array = array(2, "a", null, 2.5, NULL, 0, "", 8);
function is_notnull($v) {
return !is_null($v);
}
print_r(array_filter($my_array, "is_notnull"));
This is well readable.