Microsoft
Software
Hardware
Network
Question : Need to convert a Single byte obtained from text file to an integer in PHP
Be forwarned- extremely new to PHP.
I am reading a text file from disk and I need to read the contents byte for byte. Every XX number of characters is a single-byte that represents a short integer value. How do I convert a single-byte into an integer? The single-byte will represent a number from 0 to 255.
$fhandle = fopen($this->FilePath, 'r');
$rowID = unpack('S', fread($fhandle, 2)); //works fine with 2 bytes;
echo 'ROW ID = '.$rowID[1]; //I have the ROW ID
$rowLength = unpack('S', fread($fhandle, 1)); //errors out with single byte
Thanks!
j
Answer : Need to convert a Single byte obtained from text file to an integer in PHP
ok thats ok, because you are getting the character representacion of the ascii code, you need to translate the character to he ascii code.
To do that use the function ord ().
http://www.php.net/manual/
en/functio
n.ord.php
i hope it works
Random Solutions
return max for each group
RPC through HTTP keeps prompting for pw on Exchange 2010
Upgrade PHP to 5.3 version (or 5.2 eventually) on Plesk 9.5.2
download file with as3
Please suggest a suitable router
Disable Wireless adapters when Laptops are connected to LAN
Self signed Exchange 2007 cert and Samsung Blackjack
Exchnage database restoration
Not downloading Offline address book files. A server (URL) could not be located. 0X8004010F
Backing up, virtual machines - Best Method.