Skip to content

Instantly share code, notes, and snippets.

@ss23
Created January 31, 2014 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ss23/8725212 to your computer and use it in GitHub Desktop.
Save ss23/8725212 to your computer and use it in GitHub Desktop.
<?php
// Example usage: php check.php "Please speel check thsi sentence"
// Example output: Please <speel> check <thsi> sentence
$dictionary = file('/usr/share/dict/words', FILE_IGNORE_NEW_LINES);
$words = explode(" ", trim($argv[1]));
foreach ($words as $word) {
$found = false;
foreach ($dictionary as $dictword) {
if ($dictword == $word) {
$found = true;
break;
}
}
if ($found) {
echo $word;
} else {
echo "<" . $word . ">";
}
echo " ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment