在PHP中编写一个程序,用于查找一个字符在字符串中出现的次数
feifei123
发布于 2025-02-26
阅读(13)

$val){ if (!isset($output[$val])){ $output[$val] = 1; } else{ $output[$val] += 1; } } foreach($output as $char =>$number){ echo $char." ".'appears '. $number." ".'times'."
"; } ?>
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | w appears 1 times
e appears 2 times
l appears 2 times
c appears 1 times
o appears 4 times
m appears 1 times
t appears 4 times
u appears 1 times
r appears 1 times
i appears 2 times
a appears 1 times
s appears 1 times
p appears 1 times
n appears 1 times
|
以上就是在PHP中编写一个程序,用于查找一个字符在字符串中出现的次数的详细内容,更多请关注php中文网其它相关文章!
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。