Jump to content

Optimizing this snippet.


sneamia

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/94806-optimizing-this-snippet/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.