tags:

views:

36

answers:

1

Hi,

if i filter an array with array_filter to eliminate null values, keys are preserved and this generated "holes" in the array. Eg:

The filtered version of
    [0] => 'foo'
    [1] =>  null
    [2] => 'bar'
is 
    [0] => 'foo'
    [2] => 'bar'

How can i get, instead

[0] => 'foo'
[1] => 'bar'

? Thanks

+5  A: 

You could use array_values after filtering to get the values.

Gumbo
+1, exactly what I was thinking
ILMV