Java相当于PHP str_word_count? [重复]

This question already has an answer here:

Note: I'm not looking for a word counting algorithm in Java here. I'm asking where to find str_word_count in the PHP source code.

I'm looking to recreate (verbatim, line by line if possible) the str_word_count PHP function as a Java method:

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.
    }
}

I just downloaded PHP 5.3.23's source code (tarball) and extracted. I grepped for str_word_count and did not find anything, so I'm not even sure what to look for, let alone what file to search in. Anybody have any ideas? Thanks in advance!

</div>

Well you should look better :) It should be available in the latest stable branch 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

I don't know if there is a ready made function... but: split the string by spaces into an array get the length of the array

String vals[] = myString.split("\s+"); int wordCount = vals.length;