Extracting data line by line from a text file with fread()


BEGIN PHP output

some text here 01
some text here 02
some text here 03
some text here 04
some text here 05
some text here 06
some text here 07
some text here 08
some text here 09
some text here 10
some text here 11
some text here 12
some text here 13
some text here 14
and text added 060
611

END PHP output
<?php
$filename = "test.txt";
$fp = fopen( $filename, "r" ) or die("Couldn't open $filename");
while ( ! feof( $fp )) {
    $chunk = fread( $fp, 18);
    print "$chunk<br />";
}
?>