Moving Around a File with fseek() : fseek « File Directory « PHP






Moving Around a File with fseek()

 
<html>
<head>
<title>Moving Around a File with fseek()</title>
</head>
<body>
<div>
<?php
    $filename = "data.txt";
    $fp = fopen( $filename, "r" ) or die("Couldn't open $filename");
    $fsize = filesize($filename);
    $halfway = (int)( $fsize / 2 );
    print "Halfway point: $halfway <br/>\n";
    fseek( $fp, $halfway );
    $chunk = fread( $fp, ($fsize - $halfway) );
    print $chunk;
?>
</div>
</body>
</html>
  
  








Related examples in the same category

1.Constant Reference Points for fseek()
2.Using the fseek() Function