I have this array:
array{
0 => string '1' (length=1)
1 => string '18' (length=2)
2 => string '18' (length=2)
3 => string '1' (length=1)
4 => string '1' (length=1)
5 => string '1' (length=1)
6 => string '1' (length=1)
7 => string '1' (length=1)
8 => string '18' (length=2)
9 => string '18' (length=2)
}
I want to make it looks like this:
array{
0 => array (
0 => '1'
)
1 => array (
0 => '18'
1 => '18'
)
2 => array (
0 => '1'
1 => '1'
2 => '1'
3 => '1'
4 => '1'
5 => '1'
)
3 => array (
0 => '18'
1 => '18'
)
}
So the idea is, i want to group the array by finding if the next array key is the same as the current key, if the next array key is the same as the current one, it merges it inside a new array, like grouping.
i couldn't really find an answer here, or on google, the idea is there is key 1 then 2 the 1 again, i want to group the similar keys until a different key comes in, the key (2) broke the grouping and started a new group, then broke by key 1 to start a new group as well,
the idea is for chatting messages, facebook and msn they group the messages by the user who sent them, untill another user comes in and break the group. but can't find out how.
Thanks