note 30503 added to function.file

From: Date: Thu, 20 Mar 2003 15:36:27 +0000
Subject: note 30503 added to function.file
Groups: php.notes 
Request: Send a blank email to php-notes+get-45557@lists.php.net to get a copy of this message
Note: Now that file() is binary safe it is 'much' slower than it used to be. If you are planning to read large files it may be worth your while using fgets() instead of file() For example: $fd = fopen ("log_file.txt", "r"); while (!feof ($fd)) { $buffer = fgets($fd, 4096); $lines[] = $buffer; } fclose ($fd); The resulting array is $lines. I did a test on a 200,000 line file. It took seconds with fgets() compared to minutes with file(). -- http://www.php.net/manual/en/function.file.php http://master.php.net/manage/user-notes.php?action=edit+30503 http://master.php.net/manage/user-notes.php?action=delete+30503 http://master.php.net/manage/user-notes.php?action=reject+30503

« previous php.notes (#45557) next »