How can I search for word in text file (Text.txt) using php and give me true if this word is found else false
Thanks
Printable View
How can I search for word in text file (Text.txt) using php and give me true if this word is found else false
Thanks
First you open the file, and read it:
(Of course you can also use fopen, but this is shorter)PHP Code:$file=join('',file('text1.txt'));
Then you look for the word:
PHP Code:if (strpos($word,$file)!==false) //I'm not sure on the order of the arguments, maybe it should be the other way around
echo 'word found';
else
echo 'word not found';