How to count the number of words in a string with PHP

1 Answer

0 votes
$str = 'PHP is a general-purpose scripting language geared towards web development';
  
echo str_word_count($str);

  
  
/*
run:
    
10
    
*/

 



answered Aug 14, 2021 by avibootz
edited Nov 1, 2025 by avibootz
...