1

我有一个数组,当我运行时,print_r($array)我得到:

Array
(
    [XS] => 110
    [S] => 171
    [M] => 172
    [L] => 171
    [XL] => 171
    [2X] => 172
    [3X] => 154
    [4X] => 139
    [5X] => 47
    [6X] => 32
    [OSFA] => 12
    [FITTED S-M] => 12
    [FITTED L-XL] => 12
    [ADJ] => 52
    [YXS] => 15
    [YSM] => 20
    [YMD] => 20
    [YLG] => 20
    [YXL] => 17
    [TLG] => 1
    [TXL] => 1
    [T2X] => 1
    [T3X] => 3
    [S-M FLEX] => 3
    [M-L FLEX] => 3
    [L-XL FLEX] => 3
    [CHILD STRETCH] => 1
    [S/M] => 1
 )

我想对其进行降序排序,但arsort返回 1。我可以使用 for 循环对其进行排序,但我想要最好的解决方案。有什么建议吗?

4

1 回答 1

2

使用arsort($icon,SORT_NUMERIC);您可以将数据排序为数字将您的数据放在 $icon

于 2013-02-01T11:26:28.393 回答