I can explain what exactly I want.
Say I have five subjects (A, B, C, D, E), and each subject has an exam every day from Monday through Friday (i.e. 5 day buckets). So the $buckets array looks something like this:
$buckets = [
[A2, B2, C2, D2, E2],
[C3, A3, D3, B3, E3],
[B4, D4, C4, E4, A4],
[E5, B5, C5, A5, D5],
[A6, B6, D6, C6, E6],
];
After separating by subject, I end up with:
$subjects = [
'A' => [A2, A3, A4, A5, A6],
'B' => [B2, B3, B4, B5, B6],
'C' => [C2, C3, C4, C5, C6],
'D' => [D2, D3, D4, D5, D6],
'E' => [E2, E3, E4, E5, E6],
];
Now what i want is, from above to arrays, i want to flatten like this:
$buffers = [
[A2, B2, C2, D2, E2],
[A3, B3, C3, D3, E3],
[A4, B4, C4, D4, E4],
[A5, B5, C5, D5, E5],
[A6, B6, C6, D6, E6],
]
Then if I flatten that and pick the first five, I end up with only the exams from Monday and none from the other days.
The desired output I want is, should cover multiple days and multiple subjects and uniquely; in this case, one possible selection could be [B2, D3, A4, E5, C6] (i.e. one from each day, different subject at random each day).
Any suggestion on how can I achieve that? Basically i want to do two things here, how to generate $buffer array and how to get desired output from it.
Thank you!