Re: complex array
| From: | Chhai T | Date: | Thu, 06 May 2004 00:56:57 +0000 |
| Subject: | Re: complex array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185490@lists.php.net to get a copy of this message | ||
Thanks Torsten! It works fine.
Regards,
Chhai
<roehr@zilleon.com> wrote in message
news:E1BLHfd-00056e-00@config4.kundenserver.de...
> Chhai T <chhait@frontierisp.net.au> schrieb am 05.05.2004, 09:55:25:
> > Is there an easier, quicker way to access the values in this array
returned
> > from a SOAP request? This is the result of my print_r() :Array
> > (
> > [0] => Array
> > (
> > [name] => xxxx [description] => yyyyy
> > [members] => Array
> > (
> > [0] => Array
> > (
> > [group] => abc )
> >
> > [1] => Array
> > (
> > [group] => cdf
> > )
> >
> > )
> >
> > )
> >
> > [1] => Array
> > (
> > [name] => kkkkkk [description] => bbbbbbb
> > [members] => Array
> > (
> > [0] => Array
> > (
> > [group] => jkl
> > )
> >
> > [1] => Array
> > (
> > [group] => lmn
> > )
> >
> > [2] => Array
> > (
> > [group] => Mnop
> > )
> >
> > )
> >
> > )
> >
> > )Currently, I to access the members array, I have to do this:
> > foreach($result as $rows)
> > {
> > foreach ($rows as $key=>$val)
> > {
> > #print "$key = $val
> > } foreach ($rows[members] as $row2)
> > {
> > foreach ($row2 as $key2=>$val2) { print "$key2 =
> > $val2
> > } }}Thanks,Chhai
>
> What about this:
>
> $count = count($result);
> for ($i = 0; $i < $count; $i++) {
>
> $tempCount = count($result[$i]['members']);
> for ($k = 0; $k < $tempCount; $k++) {
>
> echo $result[$i]['members'][$k]['group'];
> }
> }
>
> This should output the groups. Heven't tested it, though.
>
> Regards, Torsten