我有这个示例数组,我想按以下顺序对每个第一级项目(66000
, 66001
, 66002
)进行排序:New Store
列表中的第一个,列表中的Store Relocation
第二个,并且我没有包含Underperforming Stores
在示例数组中,但那些将是最后一个. 然后需要按open
日期对它们进行排序我怎样才能以这种方式对它们进行排序?
我相信我需要使用usort
来完成这个,但我不太了解这个usort
功能,我可以得到帮助吗?
到目前为止,这是我的功能......
usort($mainpgArr, function($a, $b){
});
示例原始数组:
Array(
[66000] => Array(
[January] => Array(
[status] => New Store
[sales] => 100.00
[open] => 2013-05-01
)
[February] => Array(
[status] => New Store
[sales] => 200.00
[open] => 2013-05-01
)
[March] => Array(
[status] => New Store
[sales] => 140.00
[open] => 2013-05-01
)
)
[66001] => Array(
[January] => Array(
[status] => Store Relocation
[sales] => 3400.00
[open] => 2013-07-01
)
[February] => Array(
[status] => Store Relocation
[sales] => 1340.00
[open] => 2013-07-01
)
[March] => Array(
[status] => Store Relocation
[sales] => 1550.00
[open] => 2013-07-01
)
)
[66002] => Array(
[January] => Array(
[status] => New Store
[sales] => 1050.00
[open] => 2013-01-01
)
[February] => Array(
[status] => New Store
[sales] => 1009.00
[open] => 2013-01-01
)
[March] => Array(
[status] => New Store
[sales] => 1020.00
[open] => 2013-01-01
)
)
)
示例最终数组
Array(
[66002] => Array(
[January] => Array(
[status] => New Store
[sales] => 1050.00
[open] => 2013-01-01
)
[February] => Array(
[status] => New Store
[sales] => 1009.00
[open] => 2013-01-01
)
[March] => Array(
[status] => New Store
[sales] => 1020.00
[open] => 2013-01-01
)
)
[66000] => Array(
[January] => Array(
[status] => New Store
[sales] => 100.00
[open] => 2013-05-01
)
[February] => Array(
[status] => New Store
[sales] => 200.00
[open] => 2013-05-01
)
[March] => Array(
[status] => New Store
[sales] => 140.00
[open] => 2013-05-01
)
)
[66001] => Array(
[January] => Array(
[status] => Store Relocation
[sales] => 3400.00
[open] => 2013-07-01
)
[February] => Array(
[status] => Store Relocation
[sales] => 1340.00
[open] => 2013-07-01
)
[March] => Array(
[status] => Store Relocation
[sales] => 1550.00
[open] => 2013-07-01
)
)
)