Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Dave Turner
April 27, 2005, 7:00 am
rate this thread
$fp = fopen ("binary.dat", "wb");
$buffer = 12345;
fwrite ($fp, $buffer);
That creates a file 5 bytes long that contains the text data "12345", but I
need it to save that value as 32-bits instead (so the file would just be 4
bytes, with the contents being 0x39300000).
Anyone know how to do that?
Re: How to save numeric value as a 32bit number rather than string?
$someNum = 12345;
Convert to binary:
$binNum = base_convert($someNum, 10, 2);
Convert to hex:
$hexNum = base_convert($someNum, 10, 16);
- » make html page and store on harddrive from database for pagination technigue
- — Previous thread in » PHP Scripting Forum