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