Jump to content

loop exit question


pouncer

Recommended Posts

	function Is_Word_In_Search($word) {
		$file = "../search_strings.txt";

		$fp = fopen($file, "r");
				  
		while (!feof($fp)) {
			$line = fgets($fp, 4096);
			$line = trim($line);

			if ($line == $word) {
				return TRUE;
				break;
			}
		}

		return FALSE;
	}

 

is that ok guys, if it finds the word in the file, i want it to return true, otherwise false..

Link to comment
https://forums.phpfreaks.com/topic/46125-loop-exit-question/
Share on other sites

This is my functions in my class Lookup

 

	function Get_Query_String($string) {
		$wordArr = str_word_count($string, 1);

		$ret = "";

		foreach ($wordArr as $word) {
			if (this->Is_Word_In_Search($word) == TRUE) {
				$ret .= $word;
			}
		}

		return $ret;
	}


	function Is_Word_In_Search($word) {
		$file = "../search_strings.txt";

		$fp = fopen($file, "r");
				  
		while (!feof($fp)) {
			$line = fgets($fp, 4096);
			$line = trim($line);

			if ($line == $word) {
				return TRUE;
				break;
			}
		}

		return FALSE;
	}

 

then in my collection file i do:

 

$search = new Lookup();

echo $search->Get_Query_String($word);

 

it gives the bool error

Link to comment
https://forums.phpfreaks.com/topic/46125-loop-exit-question/#findComment-224153
Share on other sites

sprry im not getting anything

 

could you post all your code, included files first then the master "includer" if your got any includes please if that of, it just helps to know what your including before reading the full code, bcauase it stopd you from jumping all around the page

 

Link to comment
https://forums.phpfreaks.com/topic/46125-loop-exit-question/#findComment-224165
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.