Created
January 31, 2014 01:47
-
-
Save ss23/8725212 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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