I'm looking for a way to read the LAST line of a file w/ one PHP fopen or fgets command. Is that possible?

I thought something like this would work:

$last_row = fread($handle, (feof($handle)-1));

OR

$last_row = fread($handle, -1);

But neither of those get it. Any ideas?

    How about with zero "fopen()" or "fgets"?

    $file_arr = file($filename);
    $last_row = $file_arr[count($file_arr) - 1];
    
      12 years later
      Installer;10559603 wrote:

      How about with zero "fopen()" or "fgets"?

      $file_arr = file($filename);
      $last_row = $file_arr[count($file_arr) - 1];
      

      Thank You very much! (Before this very good indeed solution, for windows i've seen one day of rubbish).😃

        18 days later

        Thank You very much! (Before this very good indeed solution, for windows i've seen one day of rubbish).

          Write a Reply...