Tell me how to count the number of unique words in the text? This function counts all the words in the text:
count($rows); Tell me how to count the number of unique words in the text? This function counts all the words in the text:
count($rows); Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .
If $rows is a string:
$rows = "Hello frind, you're looking looking looking good today!"; $couns_words = str_word_count($rows, 1); $unique_array = array_count_values($couns_words); print_r($unique_array); $count_unique = count($unique_array); print_r($count_unique); //или $count_unique = count(array_unique($couns_words)); print_r($count_unique); Or something like:
$couns_words = preg_split('/\s+/',$rows); $count_unique = count(array_unique($couns_words)); print_r($count_unique); Source: https://ru.stackoverflow.com/questions/598201/
All Articles
$rows. if key => value (word) - then through php.net/manual/ru/function.array-unique.php ........ if there are whole lines, then it is different. need more information - Alexey Shimanskycountcannot count the number of words. Need more information that you have, that where it is transmitted. ....... if with the Input the words separated by a space are separated, then at the beginning applyexplode,trimand thenarray_unique,count- Alexey Shimansky