2011-07-15 53 views
0

我在PHP中有一个数组,看起来像这样:订购PHP数组基于内容

Array 
(
    [2] => post4.post 
    [3] => post7.post 
    [4] => post5.post 
    [5] => post3.post 
    [6] => post6.post 
    [7] => post1.post 
    [8] => post2.post 
) 

我怎么能安排它,所以它看起来是这样的?

Array 
(
    [0] => post7.post 
    [1] => post6.post 
    [2] => post5.post 
    [3] => post4.post 
    [4] => post3.post 
    [5] => post2.post 
    [6] => post1.post 
) 

该数组有一个包含在文件夹中的文件的列表。在我的本地服务器看起来像第二个例子,但在标准服务器上看起来像第一个例子。

在此先感谢:d

回答

0

您不想使用rsort,因为它会重新分配数组索引。请使用arsort()

+2

从他的例子看来,他想要重新分配索引。 –

+1

我可以发誓,当我第一次读这个问题时,索引得以维持。 – brezanac