在php中按键排序数组

时间:2018-02-05 09:30:30

标签: php arrays sorting ksort

我有一个数组如下: -

Array
(
    [Total] => Array
        (
        [ven_name] => 4DL Bangladesh Limited
        [cr_project_code] => V101
        [analytical] => 0000

        [branch] => 101

        [company] => 01
        [cost_center] => A000

        [natural_acount] => 5012901

        [ratio_per] => 30
        [future_code] => M133

        [cr_total] => -251666.99605749
    )

[Corporate] => Array
    (
        [ven_name] => 4DL Bangladesh Limited
        [cost] => -1845.5448542094
        [project_code] => 0000

        [analytical] => 0000

        [branch] => 101

        [company] => 01
        [cost_center] => A000

        [natural_acount] => 5012901

        [ratio_per] => 30
        [future_code] => M133

    )

[Other] => Array
    (
        [ven_name] => 4DL Bangladesh Limited
        [cost] => -122.54912525667
        [project_code] => 0000

        [analytical] => 0000

        [branch] => 101

        [company] => 01
        [cost_center] => A000

        [natural_acount] => 5017401

        [ratio_per] => 30
        [future_code] => M112

    )

[PCO] => Array
    (
        [ven_name] => 4DL Bangladesh Limited
        [cost] => -10517.300845996
        [project_code] => 0000

        [analytical] => 0000

        [branch] => 101

        [company] => 01
        [cost_center] => A000

        [natural_acount] => 5012901

        [ratio_per] => 30
        [future_code] => M131

    )

)

我想以这种方式对这个数组进行排序

Array
(

[Corporate] => Array
    (
        [ven_name] => 4DL Bangladesh Limited
        [cost] => -1845.5448542094
        [project_code] => 0000

        [analytical] => 0000

        [branch] => 101

        [company] => 01
        [cost_center] => A000

        [natural_acount] => 5012901

        [ratio_per] => 30
        [future_code] => M133

    )

[Other] => Array
    (
        [ven_name] => 4DL Bangladesh Limited
        [cost] => -122.54912525667
        [project_code] => 0000

        [analytical] => 0000

        [branch] => 101

        [company] => 01
        [cost_center] => A000

        [natural_acount] => 5017401

        [ratio_per] => 30
        [future_code] => M112

    )

[PCO] => Array
    (
        [ven_name] => 4DL Bangladesh Limited
        [cost] => -10517.300845996
        [project_code] => 0000

        [analytical] => 0000

        [branch] => 101

        [company] => 01
        [cost_center] => A000

        [natural_acount] => 5012901

        [ratio_per] => 30
        [future_code] => M131

    )

[Total] => Array
    (
        [ven_name] => 4DL Bangladesh Limited
        [cr_project_code] => V101
        [analytical] => 0000

        [branch] => 101

        [company] => 01
        [cost_center] => A000

        [natural_acount] => 5012901

        [ratio_per] => 30
        [future_code] => M133

        [cr_total] => -251666.99605749
    )

)

0 个答案:

没有答案