← All docs
str_word_count()
Counts the words in a string, or returns them as a list or byte-offset map.
str_word_count()
function str_word_count(string $string, int $format = 0, ?string $characters = null): array|int
Counts the words in a string, or returns them as a list or byte-offset map.
Parameters:
$string(string)$format(int), default0, optional$characters(?string), defaultnull, optional
Returns: array|int
Availability
- Compiled (AOT): supported by the Elephc code generator.
eval()(magician interpreter): supported — declarative interpreter builtin (crates/elephc-magician/src/interpreter/builtins/string/str_word_count.rs).
No examples yet — check examples/ and showcases/ for usage patterns.
Internals
For how str_word_count is implemented in the compiler, see the internals page.