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
SBS 2008 Small Business Server Internet Activity
Block Logme internally
Add Spanish dictionary in to Office 2007 english
Difference between Icefaces,myfaces,richfaces
in JSF?
acronis disk director server 10
How many keywords is too many in the meta data?
HP z200 Workstation Windows 2008 R2 'PCI serial port' driver and 'PCI Simple Communications controller' driver needed
Is there a way to wrap text in a floated div displayed inline
Offline address book cannot be downloaded after moving mailbox to exchange 2010
open Firmware