Re: How to save number to file at bin type ?

From: Date: Thu, 03 Aug 2000 18:36:39 +0000
Subject: Re: How to save number to file at bin type ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-10001@lists.php.net to get a copy of this message
Do something like this: $fp = fopen('data.bin','w'); $data = chr(0x00) . chr(0xff) . chr(0x00) . chr(0x04) . chr(0xd2) . chr(0x07) . chr(0x3b) . chr(0x91) . chr(0x57); fputs($fp,$data); fclose($fp); You can figure out how to convert your array into the right bytestream, but writing it shouldn't be an issue. The above code generates a 9 byte file for me: ~> od -t x1 data.bin 0000000 00 ff 00 04 d2 07 3b 91 57 0000011 -Rasmus On Thu, 3 Aug 2000 php_list@citiz.net wrote: > Hello php-general, > > First, I must say sorry for my english poor. > > I have an array('255','1234','121344343'), I want save it at > file: > > file size = 9 byte > ########################## > 00 FF 00 04 D2 07 3B 91 57 > ^^^^^ ^^^^^^^^ ^^^^^^^^^^^ > 255 1234 121344343 > ########################## > > not > > file size = 16 byte > ################################################# > 32 35 35 31 32 33 34 31 32 31 33 34 34 33 34 33 > 2 5 5 1 2 3 4 1 2 1 3 4 4 3 4 3 > ################################################# > > btw: dec(255) = hex(0xFF), dec(1234) = hex(0x04D2), > dec(121344343) = hex(0x073B9157) > > asc("2") = hex(0x32), asc("5") = hex(0x35), > > So, I mean "I want retrench file size, Then file can be transfer > fast", And how to output it to user browser ?? > >

« previous php.general (#10001) next »