Trying in a loop to copy the array so that each word in the file has become an element of the array
the file itself is a
test test netest
<?php$flag=0;$lines = file('file.txt');foreach ($lines as $line_num => $line) { echo $line . "
\"; if ($line=='test') { $flag=1; } } echo $flag; ?>
Information it displays line by line and it seems all right, but the problem is that if the last word in the file is not "test" the variable flag displays 0 even if the word "test" is in the file, who will able to answer why this is so, because in a loop, display all the words including "test" and the flag should be set to 1?