| 
	
 | 
 Posted by Fred Atkinson on 07/12/05 16:26 
On Tue, 12 Jul 2005 10:13:02 +0200, "Hilarion" 
<hilarion@SPAM.op.SMIECI.pl> wrote: 
 
>>><?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; 
>>>?> 
>> 
>> I tried the above and I put the path to the log file in lines 
>> 5 and 12.  I get the following error message when I pull it up: 
>> 
>> Parse error: syntax error, unexpected '}' in 
>> c:\www\mishmash.org\public_html\test\index.php on line 16 
>> 
>> I tried putting a ; after the } on line 16, but it yielded the 
>> same error message. 
> 
>Put it _before_ the "}". 
> 
> 
>Hilarion  
 
	That got it.  There were currently 12 records in the file I 
was looking at.  It returned 1212.  So, I deleted:  
 
/* 
  * for a small file 
  */ 
$linecount = count(file('file.txt')); 
echo $linecount; 
 
	Now it returns 12.   
 
	Thanks,  
 
 
						Fred
 
  
Navigation:
[Reply to this message] 
 |