我想按内部数组项的数量( count() )降序(即大多数项优先)对数组进行排序
这是我的数组,
Array
(
[Itm01] => Array
(
[0] => Array
(
[id] => 238
[col1] => 7908
[col2] => 7181
)
[1] => Array
(
[id] => 17024
[col1] => 1039
[col2] => 7181
)
[2] => Array
(
[id] =>
[col1] => 1039
[col2] => 7181
)
)
[Itm02] => Array
(
[0] => Array
(
[id] => 260
[col1] => 1039
[col2] => 8964
)
[2] => Array
(
[id] => 238
[col1] => 9149
[col2] => 8964
)
[3] => Array
(
[id] => 238
[col1] => 0
[col2] => 8964
)
[4] => Array
(
[id] => 238
[col1] => 7333
[col2] => 8964
)
[5] => Array
(
[id] => 238
[col1] => 9049
[col2] => 8964
)
[6] => Array
(
[id] => 238
[col1] => 7333
[col2] => 8964
)
[7] => Array
(
[id] => 238
[col1] => 9049
[col2] => 8964
)
但我希望索引为“Itm02”的项目作为第一个项目,因为它有更多项目。老实说,我想要和这个线程一样的东西。但是当我这样做时,
$warehouses = uksort($warehouses, function($a, $b) { return count($b) - count($a); });
但它返回一个空数组。如果有人可以提供帮助,那就太好了。
小唯快跑啊
PIPIONE