note 51038 deleted from function.fread by googleguy

From: Date: Tue, 22 Oct 2013 10:16:41 +0000
Subject: note 51038 deleted from function.fread by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196968@lists.php.net to get a copy of this message
Note Submitter: james at reflexive dot net ---- You will probably want to call unpack() if you are trying to read binary data out of a file and you want to interpret the data you read (rather than just passing it through to a browser). For example, if you were reading the header if a binary file format such as a BMP image file you would need to read 4 byte integers out of the binary file. fread() will return the binary data in a string. unpack() will let you extract data out of the string an use it as a number. <?php function Read32BitLittleEndianIntFromBinaryFile($FileHandle) { $BinaryData = fread($FileHandle, 4); $UnpackedData = unpack("V", $BinaryData); return $UnpackedData[1]; } ?>

« previous php.notes (#196968) next »