PDA

Click to See Complete Forum and Search --> : Search text file


prokhaled
Feb 17th, 2002, 06:14 AM
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

twanvl
Feb 17th, 2002, 08:37 AM
First you open the file, and read it:

$file=join('',file('text1.txt'));

(Of course you can also use fopen, but this is shorter)

Then you look for the word:

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';