Created
December 1, 2011 15:53
-
-
Save robwilkerson/1417751 to your computer and use it in GitHub Desktop.
Extremely simple PHP sample to count and return the number of lines in a text file. The output can be customised to suit your own requirements. It even seems to handle line endings nicely.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# As seen at http://www.totallyphp.co.uk/count-the-number-of-lines-in-a-text-file | |
$file = 'somefile.txt'; | |
$lines = count( file( $file ) ); | |
printf( 'There are %d line(s) in %s', $lines, $file ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment