Wednesday, March 25, 2009

PHP get number of lines in a text file

Counting number of lines in a text file is easy.

Here is the code:

$file = "file.txt";
$nr_lines = count(file($file));

Now you know how to count the number of lines in a text file with PHP.

No comments: