...

View Full Version : Finding the Amount of Lines in a file...



l3vi
05-01-2004, 08:11 PM
Hello,

I was wondering, how would I go about finding the amount of lines in a file? I have a file, and it has a lot of stuff. Ex:

55667
42aklsdf
aasdkfk6
3sdjf'as
39810-4
mmzjc


How would I find out that there are 6 lines in this file, using php?

Thanks,
l3vi



Never mind, I called up one of my friends and figured out how to do this :D If you want to know you use this line of code:




$lines = file ('filename');
$num_lines = count ($lines);

echo ("Total lines in file: " . $num_lines);

missing-score
05-02-2004, 02:31 AM
you should note that that may not be suitable to be used on every page with large files, as the file function reads the entire file, and if it has to be done many times it will slow down your system..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum