I'm having a hard time trying to explain what I want here. So I'll just try to explain it with some code:
// Example 1
$numbers = [1,2,3,4,5,6];
$in_each = 2;
$combinations = superFunction($numbers, $in_each);
// Result
$combinations = [
[
[1,2],
[3,4],
[5,6]
],
[
[1,3],
[2,4],
[5,6]
],
[
[1,4],
[2,3],
[5,6]
]
// and so on
];
// Example 2
$numbers = [1,2,3,4,5,6];
$in_each = 3;
$combinations = superFunction($numbers, $in_each);
// Result
$combinations = [
[
[1,2,3],
[4,5,6]
],
[
[1,2,4],
[3,5,6]
]
// and so on
];
It is the superFunction I need help with creating. Note the variable $in_each is key here.
The function doesn't need to be superefficient or even fail-safe. I just need something to get me started.
I've seen many different "array combo" scripts on here, but none with the option of "grouping them" like this.