RSORT()将字符串与2 [重复]

问题描述 投票:0回答:1
Array ( [0] => post9.post [3] => post8.post [4] => post4.post [5] => post7.post [6] => post5.post [7] => post10.post [8] => post3.post [9] => post6.post [10] => post1.post [11] => post2.post )

但是在尝试所有PHP数组函数之后,我无法以这种方式对其进行排序:

Array 
( 
    [0] => post10.post 
    [1] => post9.post 
    [2] => post8.post 
    [3] => post7.post 
    [4] => post6.post 
    [5] => post5.post 
    [6] => post4.post 
    [7] => post3.post 
    [8] => post2.post 
    [9] => post1.post 
)

我已经提出了这样的问题,似乎有效,但现在行不通:(

Edit:

使用后

rsort

看起来像这样: Array ( [0] => post9.post [1] => post8.post [2] => post7.post [3] => post6.post [4] => post5.post [5] => post4.post [6] => post3.post [7] => post2.post [8] => post10.post [9] => post1.post )

几乎不错,除了post10.post应该是

[0]
,并且是
[8]

    
您需要使用

natsort
php arrays sorting natural-sort
1个回答
7
投票
natsort($array); $array = array_reverse($array);

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.