j-tech
asked on
How do I convert an int to byte array in PHP?
I need to convert an integer value to a 2 byte array and then to a 2 character string to write to a text file. I obtain the value from the file using:
$fhandle = fopen($this->FilePath, 'r');
$myVal = unpack('S',fread($fhandle, 2));
echo 'My Val = '.$myVal[1]; //let's say that $myVal = 1234
How do I convert the value back to the original format from an integer?
Thank you,
j
$fhandle = fopen($this->FilePath, 'r');
$myVal = unpack('S',fread($fhandle,
echo 'My Val = '.$myVal[1]; //let's say that $myVal = 1234
How do I convert the value back to the original format from an integer?
Thank you,
j
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER