Suddenly see the number of statistics string and the problem of the weight, the heart of a thought to try the next ha. Also take the function of the array comes out, as a look at the memory of it
$a= ' EEEFFFKKKHJK ';/*********** The number of occurrences of each character in the statistics string ************/$total=Array(); for($i= 0;$i<strlen($a);$i++){ if(isset($total[$a[$i]])) { $total[$a[$i]] +=1; } Else { $total[$a[$i]] = 1; }}Var_dump($total);/*********** string de-weight *********/$b=Array(); for($j= 0;$j<strlen($a);$j++){ if(!In_array($a[$j],$b)) { Array_push($b,$a[$j]); }}Var_dump($b);$exa=Array(' E ', 2,3,3, ' e ');/*********** The number of occurrences of each value in the statistics array ************/$totals=array_count_values($exa);Var_dump($totals);/*********** Remove repeating elements in an array ************/$uni=Array_unique($exa);Var_dump($uni);
Finally, add a method, that is, the string is explode to the array, and then the use of arrays function statistics and de-weight, but also can be counted and de-weight string
String de-weight and count the characters of each character