Hi,
Friday, February 27, 2004, 4:48:20 AM, you wrote:
SG> Hi,
SG> I don't know if it's a bug in php but if I do
SG> $fp=fopen("some_file","r");
SG> while (!feof($fp))
SG> {
SG> fscanf($fp, "%d %d",&$var1,&$var2);
SG> // some treatment
SG> }
SG> fclose($fp);
SG> and the file is big enough, php eat up memory like hot cakes.
SG> But if I do
SG> $fp=fopen("some_file","r");
SG> while (!feof($fp))
SG> {
SG> $line = fscanf($fp, "%d %d");
SG> list ($var1, $var2) = $line;
SG> // some treatment
SG> }
SG> fclose($fp);
SG> It work just fine. Seems a problem with fscanf.
SG> Has someone ever experienced this? Any advises?
SG> Oh btw I'm using php 4.3.4 with Apache 1.3.29
SG> Thanks in advance
SG> S�bastien Guay
SG> _________________________________________________________________
SG> MSN Search, le moteur de recherche qui pense comme vous !
SG> http://fr.ca.search.msn.com/
Thats not the way to use scanf, I think you are doing a scanf for each
line in the file. It should be something like:
while(fscanf($fp, "%d %d",&$var1,&$var2)){
//... do something with the values
}
--
regards,
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php