gpt4 book ai didi

php - 从数组中删除元素并从 0 重新索引

转载 作者:可可西里 更新时间:2023-11-01 13:45:38 26 4
gpt4 key购买 nike

Array (
[REF_DETAILS] = Array
(
[0] = Array
(
[ID] => 1231312
[USER] => USER
)

[1] = Array
(
[TID] => 2754042
[USER] = USER
)
[1] = Array
(
[TID] => 534535
[USER] = USER
)

)

[TOTAL_COUNT] = 31
)

我有一个像上面这样的数组输出,我想从数组中删除一个元素,然后我又想从 0 重新索引它。我尝试在 php 中使用 array_value 但在这样做之后它正在删除 [REF_DETAIL] 和 0 TOTAL_COUNT 为 1 ,请提供 php 解决方案

最佳答案

使用 array_splice ( php docs ),它会自动重新索引。

array_splice($array['REF_DETAILS'], 1, 1)

关于php - 从数组中删除元素并从 0 重新索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12225888/

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