gvjvag
Last Updated: February 25, 2016
·
485
· lugat

Remove empty values from an array

There is a very easy way to remove empty values from an array without using loops.

$array = array(1, 2, '', 3, '', '', 4, 5);
var_export(array_filter($array, 'strlen')); // array(1, 2, 3, 4, 5)