gpt4 book ai didi

php - 清除php空数组

转载 作者:行者123 更新时间:2023-12-02 05:37:22 24 4
gpt4 key购买 nike

我有以下数组,想要摆脱/删除空数组并按顺序重新排列它。任何人都可以帮助我。


Array
(

[ufile] => Array
(

[name] => Array
(
[0] => chicken soup.jpg
[1] =>
[2] => hot n sour sup.jpg
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
)

[type] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
)

[tmp_name] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
)

[error] => Array
(
[0] => 1
[1] => 4
[2] => 1
[3] => 4
[4] => 4
[5] => 4
[6] => 4
[7] => 4
[8] => 4
)

[size] => Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
)

)

)

最佳答案

我相信这会清理你的数组:删除空元素(那些评估为空的元素,例如“”和 0 ),删除重复元素,然后对其进行排序。

$cleaned = array_map('array_filter', $array_to_be_cleaned);
$cleaned = array_map('array_unique', $cleaned);
$cleaned = array_map('sort', $cleaned);

关于php - 清除php空数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2886182/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com