php array_filter without key preservation
Posted
by pistacchio
on Stack Overflow
See other posts from Stack Overflow
or by pistacchio
Published on 2010-04-16T12:50:12Z
Indexed on
2010/04/16
12:53 UTC
Read the original article
Hit count: 116
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
© Stack Overflow or respective owner