elyfrank Posted March 25, 2010 Share Posted March 25, 2010 All I want is to be able to read a file until I find a word. This is the code I wrote: <?php $word="blah"; $i=0; $myFile = "http://www.example.com/file.txt"; $handle = fopen($myFile, 'r'); while($Data<>$word) { fseek($handle, $i+1); $i=$i+1; $Data = fread($handle, 4); } if ($Data = $word) echo $Data; fclose($handle); ?> And this is the error I am getting: "Warning: fseek() [function.fseek]: stream does not support seeking in ...." I keep getting this error repeatedly until it finds the word and print it. Link to comment https://forums.phpfreaks.com/topic/196544-getting-error-with-fseek/ Share on other sites More sharing options...
o3d Posted March 26, 2010 Share Posted March 26, 2010 $position = strpos(file_get_contents('file/name'), $word); if (!position) { echo 'word not found'; } Link to comment https://forums.phpfreaks.com/topic/196544-getting-error-with-fseek/#findComment-1031964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.