1. Method One, Cong Yaje learn the Hashtable method
<?php
$str = "sjdfnmy09j9re9huhdsfds99$$$543298sdjfdsj,###";
$arr = Str_split ($STR);
for ($i = 0; $i < count ($arr), $i + +) {
$index = $arr [$i];
@ $hashtable [$index] + +;
}
Arsort ($hashtable);
2. Method Two, it turns out I might write this.
<?php
$str = "sjdfnmy09j9re9huhdsfds99$$$543298sdjfdsj,###";
$arr = Str_split ($STR);
foreach ($arr as $key = + $val) {
if (!@ $count [$val]) {
$count [$val] = 1;
}
else{
$count [$val] + +;
}
}
Arsort ($count);
Var_dump ($count);
3. Finally, PHP has actually encapsulated the Array_count_values function-the number of occurrences of all the values in the statistics array, so ... This is all you need:
<?php
$str = "sjdfnmy09j9re9huhdsfds99$$$543298sdjfdsj,###";
$arr = Str_split ($STR);
$arr = Array_count_values ($arr);
Arsort ($arr);
Var_dump ($arr);
Results: