word count
word count
Out of context: Reply #8
- Started
- Last post
- 9 Responses
- squidbrains0
doesn't account for punctuation. doesn't sub-sort the words with same frequency.
$file = file_get_contents('./lotta_words... true);
$words = explode(' ', $file);
$counts = array();
foreach($words as $word) {
if ( ! isset($counts[$word])) {
$counts["$word"] = 1;
} else {
$counts["$word"]++;
}
}
asort($counts);foreach($counts as $word => $count) {
echo "$word : $count<br />";
}