重新索引数字数组键 [英] Re-index numeric array keys

查看:25
本文介绍了重新索引数字数组键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 explode() 函数构建的数组,但是看到我如何将它与随机/动态数据一起使用,我看到索引不断变化:

I have an array that is built using the explode() function, but seeing how i'm using it with random/dynamic data, i see that the indexes keep changing:

Array
(
    [2] => Title: Warmly little before cousin sussex entire set Blessing it ladyship.
    [3] => Snippet: Testing
    [4] => Category: Member
    [5] => Tags: little, before, entire
)

我需要数组总是从 0 开始排序.我正在用不同的数据进行测试,有时它从 0 开始,而在其他测试中,它从不同的数字开始.我研究并遇到了数组从零开始,但似乎只适用于该用户的特定情况.我用来构建数组的代码可以在这里看到:https://stackoverflow.com/a/10484967/1183323

I need the array to be ordered starting at 0 always. I am testing with different data and sometimes it starts at 0, and with other tests it begins at different numbers. I researched and came across Array starting at zero but it seems that only applied to that users specific case. The code i'm using to build the array can be seen here: https://stackoverflow.com/a/10484967/1183323

我该怎么做?

推荐答案

$your_new_array = array_values($your_old_array);

这篇关于重新索引数字数组键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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