Get the number of words in the string.
public wordCount ( integer $format ) : mixed | |
||
$format | integer | Specify the return format: 0 - return number of words 1 - return an ArrayObject containing all the words found inside the string 2 - returns an ArrayObject, where the key is the numeric position of the word inside the string and the value is the actual word itself |
Результат | mixed | |
An ArrayObject or integer, based on the wanted $format, with the stats about the words in the string. |
/** * @dataProvider stringSet */ public function testWordCount3($str) { $s = new StringObject($str); $words = $s->wordCount(2); $wordCountCheck = str_word_count($str, 2); $this->assertSame($wordCountCheck, $words->val()); }