0
我有一个类似于下图所示的多维数组。我需要购买排列(这是已经完成)的阵列,和项目类型不能彼此相邻:对随机二级值的PHP数组重新排序
$productlist= array
(
[1] => Array
(
[purchases] => 929
[itemtype] => a
)
[45] => Array
(
[purchases] => 628
[itemtype] => d
)
[12] => Array
(
[purchases] => 423
[itemtype] => d
)
[22] => Array
(
[purchases] => 319
[itemtype] => c
)
[4] => Array
(
[purchases] => 312
[itemtype] => b
)
}
所以基本上,我通过这个尝试循环,并尝试将项目向上或向下移动只要itemtype不同,并试图将采购保持在最高优先级。 谢谢!