the only problem there is that
sort() overwrites the array keys...
This works, and unfortunately I don't think there's a quicker way...
note, however, how the "tie" between green and red is handled
$a = array("red", "green", "blue", "blue", "yellow", "yellow", "yellow");
$b = array_count_values( $a );
arsort( $b );
$c = array_flip( $b );
$first = array_shift( $c );
$second = array_shift( $c );
$third = array_shift( $c );
print "Most frequent value is $first<br>Second is $second<br>Third is $third";
Most frequent value is yellow
Second is blue
Third is red
that would be even more complex to deal with...