PHP |将数组中的元素移动到新位置

时间:2014-12-14 10:07:18

标签: php arrays sorting

[Project 123] => Array
    (
        [2014-12-01] => 13
        [Total] => 373
        [2014-12-02] => 12
        [2014-12-03] => 12
        [2014-12-04] => 12
        [2014-12-05] => 12
        [2014-12-06] => 12
        [2014-12-07] => 12
        [2014-12-08] => 12
        [2014-12-09] => 12
        [2014-12-10] => 12
        [2014-12-11] => 12
        [2014-12-12] => 12
        [2014-12-13] => 12
        [2014-12-14] => 12
        [2014-12-15] => 12
        [2014-12-16] => 12
        [2014-12-17] => 12
        [2014-12-18] => 12
        [2014-12-19] => 12
        [2014-12-20] => 12
        [2014-12-21] => 12
        [2014-12-22] => 12
        [2014-12-23] => 12
        [2014-12-24] => 12
        [2014-12-25] => 12
        [2014-12-26] => 12
        [2014-12-27] => 12
        [2014-12-28] => 12
        [2014-12-29] => 12
        [2014-12-30] => 12
        [2014-12-31] => 12
    )

正如您可以看到顶部的数组。有一个字段373,其中包含密钥Total

我想将其移动到数组的末尾而不更改其键Total或其值373。 是否有可能这样做。??

1 个答案:

答案 0 :(得分:1)

您可以在父数组上使用ksort()

ksort($array['Project 123']);