PDA

View Full Version : Counting lines in a script



agent007
January 19th, 2002, 19:46
Is there a way to count the number of lines in a text file using PHP? Thanks. :)

megapuzik
January 20th, 2002, 00:28
sure !


$file = file(text.txt);
$total = count($file) ;
print "there is total of".$total."lines.";


The file(x) FUNC. DONT count your lines, its put every line in an array and the count(X) count them !

agent007
January 20th, 2002, 10:54
Okay, thanks! :)