Possible Duplicate:
Remove empty array elements
I want to remove empty elements from an array. I have a string which is set to an array by explode()
. Then I'm using array_filter()
to remove the empty elements. But that does not work. See Code below:
$location = "http://www.bespike.com/Packages.gz";
$handle = fopen($location, "rb");
$source_code = stream_get_contents($handle);
$source_code = gzdecode($source_code);
$source_code = str_replace("\n", ":ben:", $source_code);
$list = explode(":ben:", $source_code);
print_r($list);
But it doesn't work, $list
still has empty elements. I have also tried doing it with the empty()
function but the outcome is the same.
array_filter
? – Sean Bright Jul 10 '12 at 18:05