Opening and Reading a File Line by Line : File Read « File Directory « PHP






Opening and Reading a File Line by Line

<html>
<head>
<title>Opening and reading a file line by line</title>
</head>
<body>
<?php
$filename = "test.txt";
$fp = fopen( $filename, "r" ) or die("Couldn't open $filename");
while ( ! feof( $fp ) ) {
   $line = fgets( $fp, 1024 );
   print "$line<br>";
}
?>
</body>
</html>


           
       








Related examples in the same category

1.Reading a Specific Character
2.Using fgets() and feof() Functions
3.Reading Specific Data from a File
4.Reading from a File
5.Reading a File with fread()
6.File read by char