How to find a word in a text file and echo the whole line in PHP

1 Answer

0 votes
$f = fopen("e:/datefile.txt", "r") or die("Error open file!");
$s = "";
$word = "Applications";
while(!feof($f)) 
{
    $s = fgets($f);
    if (strpos($s, $word) !== false)
    {
        echo $s;
        break;
    }
}
fclose($f);
    
 

/*
run:

For Web Applications 

*/

 



answered Dec 4, 2015 by avibootz
edited Dec 5, 2015 by avibootz

Related questions

1 answer 202 views
1 answer 210 views
1 answer 178 views
1 answer 174 views
1 answer 219 views
...