Skip to content
Advertisement

Remove zero values from a PHP array

I have a normal array like this

JavaScript

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).

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement