在PHP中使用array_unique后重新计算键的方法

时间:2013-09-22 15:13:55

标签: php arrays sorting

我使用array_uniqe删除数组(列表#1)中的dupliactes,但是如何重新计算它的输出(列表#2)的kyes到[0-x](列表#3):

列表#1:

 array (size=24)
          0 => string '2013-09-18' (length=10)
          1 => string '2013-09-18' (length=10)
          2 => string '2013-09-18' (length=10)
          3 => string '2013-09-18' (length=10)
          4 => string '2013-09-19' (length=10)
          5 => string '2013-09-19' (length=10)
          6 => string '2013-09-19' (length=10)
          7 => string '2013-09-19' (length=10)
          8 => string '2013-09-19' (length=10)
          9 => string '2013-09-19' (length=10)
          10 => string '2013-09-19' (length=10)
          11 => string '2013-09-20' (length=10)
          12 => string '2013-09-20' (length=10)
          13 => string '2013-09-20' (length=10)
          14 => string '2013-09-20' (length=10)
          15 => string '2013-09-21' (length=10)
          16 => string '2013-09-21' (length=10)
          17 => string '2013-09-21' (length=10)
          18 => string '2013-09-21' (length=10)
          19 => string '2013-09-21' (length=10)
          20 => string '2013-09-21' (length=10)
          21 => string '2013-09-22' (length=10)
          22 => string '2013-09-22' (length=10)
          23 => string '2013-09-22' (length=10)

列表#2:

array (size=5)
  0 => string '2013-09-18' (length=10)
  4 => string '2013-09-19' (length=10)
  11 => string '2013-09-20' (length=10)
  15 => string '2013-09-21' (length=10)
  21 => string '2013-09-22' (length=10)

列表#3:

array (size=5)
  0 => string '2013-09-18' (length=10)
  1 => string '2013-09-19' (length=10)
  2 => string '2013-09-20' (length=10)
  3 => string '2013-09-21' (length=10)
  4 => string '2013-09-22' (length=10)

1 个答案:

答案 0 :(得分:8)

$list3 = array_values($list2);