1if ($file = fopen("file.txt", "r")) {
2 while(!feof($file)) {
3 $line = fgets($file);
4 # do same stuff with the $line
5 }
6 fclose($file);
7}
8
1$handle = fopen("inputfile.txt", "r");
2if ($handle) {
3 while (($line = fgets($handle)) !== false) {
4 // process the line read.
5 }
6
7 fclose($handle);
8} else {
9 // error opening the file.
10}
11