1
<?php           
$a = 'grzn.txt';
if (strpos($a, 'word') !== false) 
{
echo 'Found';
}
?>

How i check if the "word" is in the text file "grzn.txt" ? & thanks

Mjhd
  • 31
  • 3

1 Answers1

2

You should search within a text content, not within file name.
Use file_get_contents function:

$a = 'grzn.txt';
if (strpos(file_get_contents($a), 'word') !== false) echo 'found';

http://php.net/manual/en/function.file-get-contents.php

RomanPerekhrest
  • 75,918
  • 4
  • 51
  • 91