相关疑难解决方法(0)

php array_filter没有密钥保存

如果我使用array_filter过滤数组以消除空值,则会保留密钥并在数组中生成"漏洞".例如:

The filtered version of
    [0] => 'foo'
    [1] =>  null
    [2] => 'bar'
is 
    [0] => 'foo'
    [2] => 'bar'
Run Code Online (Sandbox Code Playgroud)

相反,我怎么能得到

[0] => 'foo'
[1] => 'bar'
Run Code Online (Sandbox Code Playgroud)

php arrays

38
推荐指数
2
解决办法
1万
查看次数

标签 统计

arrays ×1

php ×1