Remove empty array values in PHP

Here’s a super easy way to remove empty values from an array in PHP: $a = array_diff($a, array(“”)); In a recent project we were reading a text file and creating an array based on each new line, so we used the same method to remove any new lines that were empty. $a = array_diff($a, array(“\n”));

Read more