I have the following array:
Array
(
[0] => 1
[1] => 1
[2] => 2
[3] => 3
[4] => 4
[5] => 5
[6] => 6
[7] => 7
[8] => 9
[9] => 9
[10] => 10
)
In the example above there are various duplicate numbers.
I want the output to be as follows:
Array
(
[0] => 0,1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8,9
[8] => 10
)
I would like to be able to create a new array and display the key in the original array as a value in the second one. This means that 0 and 1 share the same value, and 8 and 9 share the same value too.
Update:
I used the following question but I wasn't successful in achieving what I wanted as mine is a flat array. The answers I found only referred to multi-dimensional arrays.