Remove zero values from a PHP array

Solution:1

You can use this:

$result = array_diff($array, [0]);   

Solution:2

$array = array_filter($array, function($a) { return ($a !== 0); });"

if you want to remove zero AND empty values, the right code is:

$array = array_filter($array, function($a) { return ($a !== 0 AND trim($a) != ''); })