Fayyaz A Mian
Fayyaz A Mian

Reputation: 151

PHP , fgets return full content of file

I have a csv file, which have +100 lines, but I tried many sample codes, always $line returning full content of file rather line by line. I tried many sample php codes, I think there is problem with file data, but when I am opening csv file I can see 100s of lines.

<?php
    $file_handle = fopen("mycsv.txt", "r");
    while (!feof($file_handle)) {
       $line = fgets($file_handle);
       echo $line . "<br>";
    }
    fclose($file_handle);
    ?>

Any help please

Kind Regards

Upvotes: 2

Views: 440

Answers (1)

meteorite
meteorite

Reputation: 756

It looks like there is a problem with new lines in your csv file. Please check the following thread:

Excel saves tab delimited files without newline (UNIX/Mac os X)

Upvotes: 1

Related Questions