I have 2 flat arrays which are Leaders and Members. These arrays are populated while incrementing ids.
I would like to associate one leader id with a sequence of consecutive ids in the members array. If there are too many leaders and not enough consecutive sequences of members, relate the remaining leader to null
.
Example:
$leaders = [1,4,8,13];
$members = [2,3,5,6,7,9,10,11,12];
This is the result I want
$leaders = [
1 => [2,3],
4 => [5,6,7],
8 => [9,10,11,12],
13 => null
];