Here's solution 3:
<?
$fp = fopen("myfile.txt", "r");
while ( ($current_line = fgets($fp)) !== false ) {
// do stuff to the current line here
}
fclose($fp);
?>
AFAICS fgets() never returns an empty string, so we can also write:
<?
$fp = fopen("myfile.txt", "r");
while ( $current_line = fgets($fp) ) {
// do stuff to the current line here
}
fclose($fp);
?>