I want to make arrays into groups by id,
but still keep the orders, that means it might have duplicate groups,
like:
Group1 [id: 1]
Group2 [id: 2]
Group3 [id: 1]
....
...
..
.
Array:
array (
0 =>
array (
'id' => 1,
'message' => 'AAA',
'sent_on' => 1582097767
),
1 =>
array (
'id' => 2,
'message' => 'AAAQAW',
'sent_on' => 1582097770
),
2 =>
array (
'id' => 2,
'message' => 'dqwdq',
'sent_on' => 1582097772
),
3 =>
array (
'id' => 1,
'message' => 'dqwdq',
'sent_on' => 1582097773
),
4 =>
array (
'id' => 1,
'message' => 'wq',
'sent_on' => 1582097773
),
5 =>
array (
'id' => 2,
'message' => 'd',
'sent_on' => 1582097774
),
6 =>
array (
'id' => 1,
'message' => 'dew',
'sent_on' => 1582112219
)
)
Hoped result:
array (
0 =>
array (
0 =>
array (
'id' => 1,
'message' => 'AAA',
'sent_on' => 1582097767
),
),
1 =>
array (
0 =>
array (
'id' => 2,
'message' => 'AAAQAW',
'sent_on' => 1582097770
),
1 =>
array (
'id' => 2,
'message' => 'dqwdq',
'sent_on' => 1582097772
)
),
2 =>
array (
0 =>
array (
'id' => 1,
'message' => 'dqwdq',
'sent_on' => 1582097773
),
1 =>
array (
'id' => 1,
'message' => 'wq',
'sent_on' => 1582097773
)
),
3 =>
array (
0 =>
array (
'id' => 2,
'message' => 'd',
'sent_on' => 1582097774
)
),
4 =>
array (
0 =>
array (
'id' => 1,
'message' => 'dew',
'sent_on' => 1582112219
)
)
)
id=1,id=2, but in my hope it need to have five groups