dparivln22034
dparivln22034
2014-09-08 17:35

使数组键在php [duplicate]中再次从0开始

已采纳

This question already has an answer here:

I have an array called $Compare, I used the print_r() function in php:

Array ([2] => Broccoli, raw [3] => Candies, butterscotch [4] => Celery, raw [10] => Apricots, raw)

I want it the keys to be in the correct order: 0,1,2,3 not 2,3,4,10!

In the end it should look like this:

Array ([0] => Broccoli, raw [1] => Candies, butterscotch [2] => Celery, raw [3] => Apricots, raw)
</div>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • duanchu0031 duanchu0031 7年前

    Use array_values:

    $Compare = array_values($Compare);
    
    点赞 评论 复制链接分享

相关推荐