Hi Folks,
I want to do the following:
$f = fopen($filename", "r");
while( !feof($f) ) {
$len=1;
$RECSIZE=128
while($n=1;$n<=$len;$n++)
$data = fread($f, $RECSIZE);
$rectype = $data[4];
switch($rectype) {
case "A": $numARec++;
$len=1;
// do something with the
// contents of $data
break;
case "C": $numCRec++;
$len=2; // at least!
// do something with the
// contents of $data
break;
case "E": $numERec++;
$len=1;
// do something with the
// contents of $data
break;
} /* switch */
fclose($f);
} /* while */
This snippet reads a data file in 128 bytes truncs
and needs to analyse the contents. As each 128 bytes
trunc has a certain structure (say: fields to access)
I would appreciate a thing like a C "struct" or so.
In C I could eaysly read the RECSIZE bytes into a
struct and access certain bytes via a "named" part
of it. Is there anything similar to this in PHP? I
couldn't find a "struct" or so in the manual. The
site's search engine said 41 hits for "struct" in
the Web Site content, but didn't show the matching
docs?! I need help on "struct" from you guys!
TIA
-Arne
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] something like a C "struct" or "union" in PHP?
Arne Borkowski \(borko.net\) Sat, 05 May 2001 02:14:55 -0700
- Re: [PHP] something like a C "struct&quo... Arne Borkowski \(borko.net\)
- Re: [PHP] something like a C "struc... Yasuo Ohgaki
- RE: [PHP] something like a C "s... Arne Borkowski \(borko.net\)

