Q:

Sort and show array in php

Ok i have this:
array(2, 2, 2, 2, 2, 3, 4, 2, 1, 2, 5, 5, 68);

I would like it to output:
There exists 6 x 2s in the array
1 x 3
1 x 4
2 x 5
1 x 68

How can i do this?

A:

Have a look at the array_count_values() function.
Example:
$arr = array(2, 2, 2, 2, 2, 3, 4, 2, 1, 2, 5, 5, 68);

foreach(array_count_values($arr) as $value => $count)
{
    printf("%d x %d<br />\n", $count, $value);
}

