[thelist] PHP - Grab bytes 10000 through 20000

David Bindel dbindel at austin.rr.com
Wed Dec 11 04:47:01 CST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I wrote this really quick function for you:

function readPartFile($filename, $begin, $read) {
	$ifstream = fopen($filename, "r");

	if (fseek($ifstream, $begin) == 0)
		echo fread($ifstream, $read);

	fclose ($fd);
}



readPartFile("file.txt", 10000, 10000); // <--- example call to
function

/*
 * opens file "file.txt",
 * starts reading at the 10000th byte,
 * reads 10000 characters from the file.
 */



HTH,

David Bindel




> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org] On Behalf Of Feingold Josh S
> Sent: Tuesday, December 10, 2002 10:12 AM
> To: 'thelist at lists.evolt.org'
> Subject: [thelist] PHP - Grab bytes 10000 through 20000
>
> I have a bunch of files that are really long and I want to
> split them into readable chunks.  For now I am starting with
> 10K.  The question I have is how to read only one chunk of
> the data from the file then send it to the browser.  I can
> get to point y in the file using fseek(). Is there a function
> that will let me read only xK from point y in a file and send
> it to standard output?

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPfcXon6TtTuKuQdTEQJvrACeI4i4rH9wbx/+ImiLgyq3oEdFUjIAn15s
lwrLsHkF4wnX8eXyBQpXVtYX
=afgf
-----END PGP SIGNATURE-----

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 12/6/2002




More information about the thelist mailing list