Remove zero values from a PHP array
You can just loop through the array and unset any items that are exactly equal to 0
foreach ($array as $array_key => $array_item) {
if ($array[$array_key] === 0) {
unset($array[$array_key]);
}
}
bit late, but copy & paste:
$array = array_filter($array, function($a) { return ($a !== 0); });
array_filter
does that. If you don’t supply a callback function, it filters all values out that equal false (boolean conversion).