Don't know about php script, but you could use "wc" in bash to could lines in a text file. For example:
wc -l filename.txt > num
You have to use exec() in php.
Another solution, you may can parse it as an array with /n (new line) as the delimiter. Then, sizeof() of count() to get the number.
Disclaimer, both methods are work arounds. There probably is a better way of doing this.
just my 0.02
Kai