unpack() based on C struct

From: Date: Thu, 26 Dec 2002 18:49:31 +0000
Subject: unpack() based on C struct
Groups: php.general 
Request: Send a blank email to php-general+get-129366@lists.php.net to get a copy of this message
Hi all, Assume we've got a binary data file 'profile' which stores the data of a C struct. The struct is as follows: struct s_profile { char id[32]; char vala:3; char valb:1; char valc:7; } Now I would like to read 'profile' using PHP's unpack(). So like this: $f = fopen('profile', 'r'); $binaryData = fread($f, filesize('profile')); $data = unpack('a32id/[...etc]', $binaryData); My problem is: which formats should I use for char vala:3, char valb:1 & char valc:7 ? In other words: what should be on the spot of [...etc] ? cvala/cvalb/cvalc doesn't work. Thanks, Tim Molendijk

« previous php.general (#129366) next »