pouncer Posted April 8, 2007 Share Posted April 8, 2007 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.. Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 8, 2007 Author Share Posted April 8, 2007 any ideas guys? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Share Posted April 8, 2007 um, looks fine, but id use $word%, so that it can be anywhere. is ther a search function for txt files. id look for one if there is good luck Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 8, 2007 Author Share Posted April 8, 2007 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) { Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Share Posted April 8, 2007 how long is your code. if its not to much longer, please post it otherwise please just post some ore if it about where you call the function adn define values etc. thankx Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 8, 2007 Author Share Posted April 8, 2007 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 Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Share Posted April 8, 2007 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 Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 8, 2007 Author Share Posted April 8, 2007 i fund the problem. i was missing $ from this shud have been $this lol Quote Link to comment Share on other sites More sharing options...
per1os Posted April 8, 2007 Share Posted April 8, 2007 No need for the break after the return true; The return statement automatically breaks the loop and that break; will never get read/touched. Just an FYI. 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.