Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
字母/符号频率(PHP)_Php_Variables - Fatal编程技术网

字母/符号频率(PHP)

字母/符号频率(PHP),php,variables,Php,Variables,如何从字符串中获取php脚本中字母或符号的频率 我正在尝试为网络制作一些字谜 使用 但要小心,因为: $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

如何从字符串中获取php脚本中字母或符号的频率

我正在尝试为网络制作一些字谜

使用

但要小心,因为:

$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