RE: [PHP] counting lines in a file?
| From: | Boget, Chris | Date: | Tue, 03 Oct 2000 16:46:17 +0000 |
| Subject: | RE: [PHP] counting lines in a file? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18446@lists.php.net to get a copy of this message | ||
> $f = fopen($filename);
> $x=0;
> while(!feof($f)){
> $tmp = fgets($f,10000000);
> $x++;
> }
> now $x contain the number of lines
Even easier:
$fileArray = file( $filename );
$numLines = count( $fileArray );
Chris