| 
 Posted by Veikko Mδkinen on 06/13/32 11:19 
Fred Atkinson wrote: 
> 	Is there a PHP function that returns the number of lines 
> (records) in a file?   
>  
 
Not that I no of, but it's fairly simple to count the lines yourself. 
 
<?php 
/* 
  * for a small file 
  */ 
$linecount = count(file('file.txt')); 
echo $linecount; 
 
/* 
  * for a big file (if you don't want to read the whole file into memory) 
  */ 
$linecount = 0; 
$handle = fopen("file.txt", "r"); 
while (fgets($handle, 4096)) 
{ 
	++$linecount 
} 
fclose($handle); 
echo $linecount; 
?> 
 
 
-veikko 
 
--  
         veikko 
mail@                     .com 
                 makinen
 
[Back to original message] 
 |