I have this example array, and I would like to sort each first level item (66000
, 66001
, 66002
) in this order: New Store
first in the list, Store Relocation
second in the list, and I didn't include Underperforming Stores
in the example array, but those would be last. those then need to be sorted by open
date How can I sort them this way?
I believe I need to use usort
to accomplish this, but I don't really understand the usort
function, can I get help with this?
Here is my function so far...
usort($mainpgArr, function($a, $b){
});
Example Original Array:
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
)
)
)
Example Final Array
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
)
)
)