Display the drop-down list

str_word_count()

« str_split | strcasecmp »
<?php
$mixed 
str_word_count (
    
// string $string
    
?// [int $format = 0]
    
  // [string $charlist]
);
?>
Result
$mixed = [
  
=> 'Hello',
  
=> 'fri',
  
10 => 'nd',
  
14 => 'you\'re',
  
28 => 'looking',
  
45 => 'good',
  
50 => 'today',
]
Examples
#1 str_word_count  ("Hello fri3nd, you're looking good today!",
 
1)
#2 str_word_count  ("Hello fri3nd, you're looking good today!",
 
2)
#3 str_word_count  ("Hello fri3nd, you're looking good today!",
 
1,
 
"àáãç3")
See also
count_chars, explode, preg_split, substr_count