alin19 Posted June 11, 2008 Share Posted June 11, 2008 i have a file and i want to read from it from byte 1024 for example, and from each line i want only to read 8 bytes, i have this code, can you help me? $handle = fopen("C:\Documents and Settings\Administrator\Desktop\sibiu\FuturesDeal.txt", "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle,; echo $buffer; echo ftell($handle); } fclose($handle); } , Link to comment https://forums.phpfreaks.com/topic/109711-reading-from-a-specific-byte/ Share on other sites More sharing options...
Vizor Posted June 11, 2008 Share Posted June 11, 2008 This would read every 8 bytes from 1024 bytes into the file. <?php $fp = fopen('file.txt', "r"); $offset = 1024; while(!feof($fp)) { echo fgets($fp, $offset); $offset += 8; } fclose($fp); ?> Link to comment https://forums.phpfreaks.com/topic/109711-reading-from-a-specific-byte/#findComment-562982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.