注意:我不在這裏尋找Java中的字數統計算法。我在問哪裏可以找到PHP源代碼中的str_word_count
。PHP的等價物str_word_count?
我期待重新創建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的源代碼(tar包)和提取。我grepped爲str_word_count
,並沒有找到任何東西,所以我甚至不知道要尋找什麼,更不用說尋找什麼文件。任何人有任何想法?提前致謝!
很好地可用,返回類型鐵定*** ***不能是int,如果你的目標是*確切*複製。 – Perception 2013-03-19 10:40:20
良好的捕獲@Perception(+1) - 我應該提到'格式'被默認處理爲0(因此將字數作爲整數類型返回)。所以我不會擔心處理任何其他'format'類型的'str_word_count'的任何部分。 – IAmYourFaja 2013-03-19 10:42:25
PHP源代碼可用,用C編寫。如果你想複製確切的算法,那就從哪裏開始。 – SDC 2013-03-19 10:44:38