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
Share on other sites

when i try to call the function from the same class file lie this

 

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

 

i get

 

syntax error, unexpected T_OBJECT_OPERATOR on line 11

 

line 11 is

if (this->Is_Word_In_Search($word) == TRUE) {

 

Link to comment
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.