RE: [PHP] something like a C "struct" or "union" in PHP?
| From: | Arne Borkowski \(borko.net\) | Date: | Sat, 05 May 2001 23:59:29 +0000 |
| Subject: | RE: [PHP] something like a C "struct" or "union" in PHP? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-51577@lists.php.net to get a copy of this message | ||
Hi Yasuo,
thanks for the hint ... I'll give WDDX a try after some thought
(and because I am using XML anyway).
Regards, Arne
> -----Original Message-----
> From: Yasuo Ohgaki [mailto:yohgaki@hotmail.com]
> Sent: Saturday, May 05, 2001 2:11 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] something like a C "struct" or "union" in PHP?
>
>
> PHP does not have struct. You can do similar things with class or
> array. You
> probably interested in wddx serialize or serialize function to
> make it work your
> snippet.
>
> Regards,
> --
> Yasuo Ohgaki
>
>
> ""Arne Borkowski (borko.net)"" <arne@borko.net> wrote in message
> news:NEBBKBGNJKHCFGAFLHOAOEKCEEAA.arne@borko.net...
> > 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: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>