I want to remove the empty and null values from $listValues array.
Here I am removed the empty values using array_filter.
Sample Code:
$listValues = array("one", "two", "null","three","","four","null");
$resultValues = array_filter($listValues);
echo "<pre>";
print_r($resultValues);
echo "</pre>";
Result:
Array ( [0] => one [1] => two [2] => null [3] => three [5] => four [6] => null )
But I want
Array ( [0] => one [1] => two [3] => three [5] => four )
Any advice greatly appreciated.
array_filter()to filter out what you wantarray_filer justapplyarray_values