几个小时以来我一直在尝试自己寻找解决方案。尝试不同的方法。我需要将一列中的所有名称加在一起,并找出每个字母出现的次数。
这就是我陷入困境的地方,它只获取列中的名字并显示有关它的信息,但我需要将它们全部放在一起
$text=mysqli_query($conn,"SELECT test from tabletest");
//Fetch result
$text=mysqli_fetch_assoc($text);
$my_id=$text['test'];
$text = str_replace(' ', '', $text );
$arrLetters = str_split($text['test']);
$countLetters = count($arrLetters);
$letters = [];
foreach($arrLetters as $letter){
if(isset($letters[$letter])){
$letters[$letter] += 1;
} else {
$letters[$letter] = 1;
}
}
foreach($letters as $letter => $total){
echo $letter.": ".$total.": ".round(($total/$countLetters*100),2)."%\n";
}
动漫人物