In PHP you have a built in function to what are you trying to achieve. You can use this function array_filter()
Here is an example:
$array = ["apple", "", null, "banana", 0, "0", [], "cherry"];
$clean = array_filter($array);
print_r($clean);
This function will remove "", null, 0, "0", and false.