Extremely simple PHP sample to count and return the number of lines in a text file. The output can be customised to suit your own requirements. It even seems to handle line endings nicely.