I have an array
array (size=7)
0 => string '2'
1 => string ''
2 => string ''
3 => string '0'
4 => string ''
5 => string ''
6 => string '2.5'
I used:-
array_filter()
to remove the null values and it returns
Array ( [0] => 2 [6] => 2 )
array_filter() removes null value and also '0' value.
Any builtin function is available in PHP to remove NULL values only.
array_filter()?array_filter($array,'strlen')Code is workedNULL. You can use a closure as your callback to control what gets filtered.array_filter()to remove the null values" -- your input array does not containNULLvalues. It contain empty strings ('') and they are not the same asNULL.NULLmeans the absence of any value, an empty string is a string of length0. They are completely different concepts.