如何从字符串中获取php脚本中字母或符号的频率。
我正在尝试为Web制作某种字谜制作器。
使用 substr_count()
但要注意,导致这个:
$text = 'This is a test';
echo substr_count($text, 'is'); // returns 2 occurences
返回 2 而不是 1,因此如果要检查单词,请使用:
$text = 'This is a test';
echo substr_count($text, ' is '); // returns 1 occurence