Skip to content

Instantly share code, notes, and snippets.

Created June 7, 2014 11:14
Show Gist options
  • Select an option

  • Save anonymous/1a8134838b06ae1bfd17 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/1a8134838b06ae1bfd17 to your computer and use it in GitHub Desktop.
<?php
$sourcefile = fopen('word.txt', 'r');
while (!feof($sourcefile)){
$cursymbol = fread($sourcefile, 1);
if ($cursymbol != " "){
$word = $word . $cursymbol;
} else {
$words[$word] += 1;
$word = null;
}
}
foreach ($words as $brand => $count) {
echo $brand . ' - ' . $count . '; ';
}
fclose($sourcefile);
?>
mac mac word ibm mac pc mac mac mac power mac ibm power
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment