sneamia Posted March 6, 2008 Share Posted March 6, 2008 if (!empty($_POST['query'])) { $dict = file_get_contents('sowpods.txt'); // Get contents of dictionary in $dict. if (strpos($dict, "\n" . strtoupper(htmlentities($_POST['query'])) . "\n") === false) { echo '<div id="no"><p>No</p></div>'; } else { echo '<div id="yes"><p>Yes</p></div>'; } } The SOWPODS dictionary is arranged like: AARDVARK AARDVARKS AARDWOLF AARDWOLVES A \n before each word, and a \n after. How would you optimize this code snippet? Quote Link to comment Share on other sites More sharing options...
fnairb Posted March 7, 2008 Share Posted March 7, 2008 If you are running on a UNIX system it may be faster to use a system call and grep the file. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.