In order to filter out values from an array and obtain a new array containing all the values that satisfy the filter condition, you can use the array_filter function.
Filtering non-empty values
The simplest case of filtering is to remove all "empty" values:
$my_array = [1,0,2,null,3,'',...