At times, we may want to tidy up an array by removing any blank values but PHP doesn't seem to have a dedicated function for this common situation. It does, however, have the 'array_filter' function that we can utilise to get what we want.
This function preserves array keys.
We can remove all 'FALSE' values (any value that PHP evaluates as false. eg. "", 0, "0", FALSE) by simply calling 'array_filter' without a second parameter.
If we only want to remove actual blank (empty) entries, we can supply a second parameter, a callback function, to 'array_filter'.
The callback function (created inside the array_filter call) takes each element of the array ($a) and only returns it if it has any non-blank value.