The str_word_count function of PHP will either count the number of words in a string, or return an array containing all the words in a string – it depends on what parameters you use with the function.
See also: Count number of words with PHP
|string||The string Itself (doh!)|
The format you want to have returned.
|charlist||A list of characters which will be considered as "word" by PHP.|
What is an reference without code examples, right? The below script is using the charlist parameter to include a few numeric characters, these will then be considered as "word" characters together with the existing alphabetic characters.
<?php $str = "Thi3s is j4ust an e8ampl9e"; print_r(str_word_count($str, 1, '3498')); echo "<br><br>"; echo 'Word Count: <strong>' . str_word_count($str, 0, '3498') . '</strong>'; ?>