Counting lines in a file : feof « File Directory « PHP
- PHP
- File Directory
- feof
Counting lines in a file
<?php
$lines = 0;
if ($fh = fopen('data.txt','r')) {
while (! feof($fh)) {
if (fgets($fh)) {
$lines++;
}
}
}
print $lines;
?>
Related examples in the same category