You can use the PHP array_filter() function to remove or filter empty values from an array. This function usually filters the values of an array using a callback function. However, if no callback is specified, all values in the array equal to FALSE will be removed, such as an empty string or a NULL value.
How to remove null or empty values from an array in PHP
<?php
$arr = array("", "lorem", 0, null, "ipsum", false);
// Filter the array
$new_arr = array_filter($arr);
print_r($new_arr);
?>
Output:
Array (
[1] => lorem
[4] => 1
[5] => ipsum
)