使用类似下面的数组,有一种方法可以让我基于总计为设定值的值来划分/拆分数组。例如,如果我希望它们小于等于250,则将其相关元素也分组到拆分数组中。
Example
Array
(
[42] => 10
[55] => 20
[56] => 10
[57] => 4
[58] => 5
[59] => 240
)
输出应如下:
Array
(
[0] => Array
(
['value'] => Array
(
[0] => 10
[1] => 20
[2] => 10
[3] => 4
[4] => 5
),
['element'] => Array
(
[0] => 42
[1] => 55
[2] => 56
[3] => 57
[4] => 58
),
)
[1] => Array
(
['value'] => Array
(
[0] => 240
),
['element'] => Array
(
[0] => 59
),
)
);