Counting lines in a file
<?php $lines = 0; if ($fh = fopen('data.txt','r')) { while (! feof($fh)) { if (fgets($fh)) { $lines++; } } } print $lines; ?>