注意:我不是在寻找 Java 中的字数统计算法。我问哪里可以找到str_word_count
在 PHP 源代码中。
我希望重新创建(逐字记录,如果可能的话逐行) str_word_count
PHP 函数作为 Java 方法:
public class PhpWordCounter {
public int strWordCount(String str) {
// The exact algorithm used in PHP's str_word_count here...
// The str_word_count method takes an optional parameter
// "format", which, if 0, returns the number of words.
// This is the portion of the routine that I will actually
// be mimicking.
}
}
我刚刚下载了 PHP 5.3.23 的源代码(tarball)并解压。我搜索str_word_count
并没有找到任何东西,所以我什至不知道要寻找什么,更不用说要搜索什么文件了。有人有什么想法吗?提前致谢!
最佳答案
好吧,你应该看起来更好:)它应该在最新的稳定分支 http://www.php.net/manual/en/function.str-word-count.php 中可用。
find . -type f -exec grep -l 'str_word_count' {} \;
./ext/standard/php_string.h
./ext/standard/tests/strings/str_word_count1.phpt
./ext/standard/tests/strings/str_word_count.phpt
./ext/standard/basic_functions.c
./ext/standard/string.c
关于Java 相当于 PHP str_word_count?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15497121/