Php Programming Code Examples Php > Code Snippets Code Examples Count the number of lines in a text file Count the number of lines in a text file <? php $file = "somefile.txt"; $lines = count(file($file)); echo "There are $lines lines in $file"; ?>