Hiya,
I need to count the lines in a text file is there a quick and easy way to do this? Or is there somewhere that I can look to find out myself (Hints on what to look for too)?
Cheers.
Tony.
filesystem options:
$aFile=file($filename); echo count($aFile); Unfortunately this requires reading the entire file into memory.
If you are on unix you can let unix do it for you:
$aCount=preg_split("/\s+/",wc -l php); echo $aCount[1];
wc -l php
I'm running on Linux so have just put in the top part of the code you specified with modified variable names and filename. It has returned the value 1 when I print the variable, any other advice you can offer me?
do a "wc -l filename" on your system from the commandline, and see what it returns. You may have to fiddle with it to grab the actual linecount.