I have a normal array like this
Array ( [0] => 0 [1] => 150 [2] => 0 [3] => 100 [4] => 0 [5] => 100 [6] => 0 [7] => 100 [8] => 50 [9] => 100 [10] => 0 [11] => 100 [12] => 0 [13] => 100 [14] => 0 [15] => 100 [16] => 0 [17] => 100 [18] => 0 [19] => 100 [20] => 0 [21] => 100 )
I need to remove all 0’s from this array, is this possible with a PHP array function
Advertisement
Answer
array_filter
does that. If you don’t supply a callback function, it filters all values out that equal false (boolean conversion).