我有一个类似于下面所示的多维数组。我需要通过购买安排的阵列(已经完成),并且项目类型不能彼此相邻:
$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不同,并尝试保持购买的首要任务。 谢谢!