Remove zero values from a PHP array
array_filter
does that. If you don’t supply a callback function, it filters all values out that equal false (boolean conversion).
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]);
}
}