Re: How does unpack works?
| From: | Tom Rogers | Date: | Tue, 21 Oct 2003 05:36:35 +0000 |
| Subject: | Re: How does unpack works? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-166899@lists.php.net to get a copy of this message | ||
Hi,
Tuesday, October 21, 2003, 3:12:47 PM, you wrote:
VE> Hi,
VE> I'm trying to extract an binary file with unpack but I don't understand
VE> how it works...
VE> The F6FBB program makes the file...
VE> It is a hamradio program http://www.f6fbb.org/
VE> This is the structure of 1 record in the file :
VE> struct inf_struct
VE> { char callsign[8]; /* Callsign */
VE> char dummy1[64];
VE> long lastmes;
VE> long connects; /* Number of connexions */
VE> long hcon;
VE> long lastyap;
VE> int flags;
VE> int on_base;
VE> char nbl;
VE> char lang;
VE> long newbanner;
VE> int download;
VE> char free[20];
VE> char thema;
VE> char nom[18];
VE> char prenom[13];
VE> char adres[61];
VE> char ville[31];
VE> char teld[13];
VE> char telp[13];
VE> char home[41];
VE> char gra[7];
VE> char priv[13];
VE> char filtre[7];
VE> char pass[13];
VE> char zip[1];
VE> } inf; /* 360 bytes = lenght of one record */
VE> Can somebody help me?
VE> Regards,
VE> Vincent
Try this (assumes little endian byte ordering, if big endian V = N v = n)
$array = unpack("
a8callsign/
a64dummy1/
Vlastmes/
Vconnects/
V/hcon/
V/lastyap/
vflags/
von_base/
cnbl/
clang/
Vnewbanner/
vdownload/
a20free/
cthema/
a8nom/
a13prenom/
a61adres/
a31ville/
a13teld/
a13telp/
a41home/
a7gra/
a13priv/
a7filtre/
a13pass/
czip",$input);
print_r($array);
--
regards,
Tom