Hey,
Take this array for example:
Array ( [0] => 130
[1] => 125
[2] => 112
[3] => 110
[4] => 108
[5] => 107
[6] => 106
[7] => 105
[8] => 102
[9] => 100
[10] => 131
[11] => 117
[12] => 100
[13] => 72
[14] => 65
[15] => 115
[16] => 72
[17] => 32
[18] => 27
[19] => 26
[20] => 23
[21] => 22
[22] => 21
[23] => 19
[24] => 12 )
The value is an article ID. I would like to remove all duplicates, however, sort the array in order with the total amount of duplicates it did have. I came up with the following function however it seems to fail at the last section:
function unique_array_counter($array){
foreach ($array as $value) {
$array2["$value"]=$array2[$value]+1;
}
sort($array2);
foreach ($array2 as $key => $value){
$newarray[] = $key;
}
return $newarray;
}
The $key => $value the returned $key is the array ID instead of the proper value of $key.. EG
It returns 0,1,2,3 instead of 233,244,22,100 (which is the key ID).
Any idea's?