Finding the halfway point in a file with fseek()


BEGIN PHP output
Halfway point: 137

ere 08 some text here 09 some text here 10 some text here 11 some text here 12 some text here 13 some text here 14 and text added 060611


END PHP output

$filename = "test.txt";
$fp = fopen( $filename, "r" ) or die("Couldn't open $filename");
$fsize = filesize($filename);
$halfway = (int)($fsize/2);
print "Halfway point: $halfway <br /><br />\n";
fseek( $fp, $halfway);
$chunk= fread( $fp,($fsize - $halfway));
print "$chunk";