php read line by line string code example
Example 1: php read file line by line
$handle = fopen("inputfile.txt", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
// process the line read.
}
fclose($handle);
} else {
// error opening the file.
}
Example 2: read line by line php
<?php
$file = new SplFileObject("file.txt");
while(!$file->eof())
{
echo $file->fgets()."<br/>";
}
$file = null;
?>