something like a C "struct" or "union" in PHP?

From: Date: Sat, 05 May 2001 09:31:39 +0000
Subject: something like a C "struct" or "union" in PHP?
Groups: php.general 
Request: Send a blank email to php-general+get-51518@lists.php.net to get a copy of this message
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

« previous php.general (#51518) next »