Re[6]: [PHP] How does unpack works?

From: Date: Wed, 22 Oct 2003 05:31:32 +0000
Subject: Re[6]: [PHP] How does unpack works?
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-167064@lists.php.net to get a copy of this message
Hi, Wednesday, October 22, 2003, 2:35:43 PM, you wrote: VE> Hi, VE> I'have found a other structure I gues... VE> You can find it here : http://www.f6fbb.org/fbbdoc/fmtinf.htm VE> (it's a very slow site...) VE> The file inf.sys is included. VE> Many thanks for helping!!! VE> Greetz, Vincent This should now work: <?php $sys = 'inf.sys'; $records = array(); $z = 0; // record counter if($fp = fopen($sys, 'r')){ while($buf = fread($fp,360)){ $relays = array(); //unpack string needs to be on one line $record = unpack("a8callsign/a64dummy1/Vlastmes/Vconnects/Vhcon/Vlastyap/vflags/von_base/cnbl/clang/Vnewbanner/vdownload/a20free/cthema/a18nom/a13prenom/a61adres/a31ville/a13teld/a13telp/a41home/a7gra/a13priv/a7filtre/a13pass/a9zip",$buf); $records[$z]['record'] = $record; //extract the relays $relbuf = substr($buf,8,64); for($x=0,$y=0;$x<8;$x++,$y+=8){ $buf2 = substr($relbuf,$y,8); $relays = unpack('a7callsign/cssid',$buf2); if(!empty($relays['callsign'])){ $records[$z]['relays'][] = $relays; } } $z++; } } print_r($records); ?> -- regards, Tom

« previous php.general (#167064) next »