I want to sort the results to a new array but without the $key so the most UNunique number will be first (or the most duplicated number will be first).
<?php
$a = array (1,1,2,2,2,3,3,3,3,4,4,4,4,4,5);
foreach (array_count_values($a) as $key => $value) {
echo $key.' - '.$value.'<br>';
}
//I am expecting to get the most duplicated number FIRST (without the $key)
//so in that case :
// $newarray = array(4,3,2,1,5);
?>
$a = array (1,1,2,2,2,3,3,3,3,4,4,4,4,4,5);
$totals = array_count_values($a);
arsort( $totals );
echo "<pre>";
print_r($totals);
Output
Array
(
[4] => 5
[3] => 4
[2] => 3
[1] => 2
[5] => 1
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With