RE: [PHP] fread()
| From: | Justin Palmer | Date: | Wed, 08 Dec 2004 20:44:30 +0000 |
| Subject: | RE: [PHP] fread() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-203762@lists.php.net to get a copy of this message | ||
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:rjones@email.unc.edu]
Sent: Wednesday, December 08, 2004 12:20 PM
To: php-general@lists.php.net
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