I believe that fread uses the handle pointer from when it was opened
so...
None of the code is tested, I just typed it in.
class FileReader
{
//private
var $handle;
function FileReader($filePath)
{
$this->handle = fopen($filePath,'r');
}
/*public*/function read($bytes)
{
return fread($this->handle,$bytes);
}
/*public*/function isEndOfFile()
{
return feof($this->handle);
}
//...
}
USAGE:
$strFile = "";
$fr =& new FileReader("example.txt");
While(!$fr->isEndOfFile())
{
$strPartialFile = $fr->read(1000);
$strFile .= $strPartialFile;
}
More at: php.net/fread
Regards,
Justin Palmer
__________________________
KISS (Keep It Simple, SEARCH)!
Google::getUri( http://www.google.com );
Archives::getUri( http://marc.theaimsgroup.com/?l=php-general );
-----Original Message-----
From: Russell P Jones [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 08, 2004 12:20 PM
To: [EMAIL PROTECTED]
Subject: [PHP] fread()
Is there any way to use fread() or a similar function to read a section
of a document NOT starting at the beginning...
for example, I can read the first 1000 bytes of a document with
fread($doc, 1000);
Is there any way to read the second 1000 bytes?
perhaps, fread($doc, 1000, 2000); who knows....
or would substr work?
russ
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php