Basic File Reading Line by Line in PHP


Read a file line by line with fgets().

Source Code

$file = fopen("test.txt", "r");
if ($file) {
    while (($line = fgets($file)) !== false) {
        echo $line;
    }
    fclose($file);
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments