PHP的array_filter无钥匙preservation [英] php array_filter without key preservation

查看:92
本文介绍了PHP的array_filter无钥匙preservation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

,如果我筛选具有array_filter阵列以消除空值,键是preserved和阵列中这个生成的洞。例如:

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'

?谢谢

推荐答案

您可以使用 array_values​​ 滤波后得到的值。

You could use array_values after filtering to get the values.

这篇关于PHP的array_filter无钥匙preservation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆