Results 1 to 2 of 2

Thread: Reading a File Line by Line

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2005
    Posts
    46,704

    Default Reading a File Line by Line

    Code:
    <?php
    
    $file= fopen("file.txt", "r") or exit ("unable to open file!");
    
    while(!feof($file))
    
    {
    echo fgets ($file) . "<br/>";
    
    }
    
    fclose($file);
    ?>

  2. #2
    Join Date
    Apr 2005
    Posts
    46,704

    Default

    Reading a File Character by Character


    Code:
    <?php
    $file=fopen("file.txt","r") or exit("Unable to open file!");
    while (!feof($file))
      {
      echo fgetc($file);
      }
    fclose($file);
    ?>
    Last edited by minisoji; 10-25-2011 at 05:24 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •