Use feof() to read through a file, line by line, until end-of-file is reached


SUBMITTED BY: henry1874w

DATE: June 17, 2017, 1:39 p.m.

FORMAT: Text only

SIZE: 256 Bytes

HITS: 314

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <?php
  5. $myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
  6. // Output one line until end-of-file
  7. while(!feof($myfile)) {
  8. echo fgets($myfile) . "<br>";
  9. }
  10. fclose($myfile);
  11. ?>
  12. </body>
  13. </html>

comments powered by Disqus