Reading large files via PHP?
| From: | Jay Paulson \(CE CEN\) | Date: | Wed, 11 Jan 2006 19:28:40 +0000 |
| Subject: | Reading large files via PHP? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-228486@lists.php.net to get a copy of this message | ||
I'm reading in a 66MB file into php so I can parse it and load it into a database. However, it
is taking a long time for php to read the file. So long that the script times out. I know about
the ini_set("max_execution_time", 120) or whatever length I want to set the time out for
the script, but my question is as follows.
Is it possible to read in a file and at the same time echo out a status of how far along the file
has been read?
The code I have right now is below. Just wondering if what I'm trying to do is possible and
how to do it.
// set script timeout
ini_set("max_execution_time", 120);
// import file name
$log_file_name = "access_log.1";
echo "Reading access log!<br/>";
if (!$ac_arr = file("./$log_file_name")) {
echo "Couldn't load access log!";
die;
}
Thanks!