thanks, I found that there is a bug. The curly braces don't make any
difference in fact ...
foreach ($fred as $fred1) foreach ($fred as $fred2) echo "$fred1 :
$fred2<br>";
is okay (but still doesn't work) although I have noticed that you seem to
need to code-block single statements in if ... else constructs
i.e
if (1==1) echo("fred") else echo("bill"):
should work but doesn't.
Another bug?.
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Chris Fry [mailto:[EMAIL PROTECTED]]
> Sent: 30 January 2001 03:56
> To: Tim Ward
> Cc: PHP News Group (E-mail)
> Subject: Re: [PHP] Nesting 'foreach ()'
>
>
> Tim,
>
> Works fine in 4.04pl1 on NT.
>
> I think you should have curly braces round the inner foreach as well?
>
> $fred = array(1,2,3,4,5,6);
> foreach ($fred as $fred1)
> { foreach ($fred as $fred2) {
> echo "$fred1 : $fred2<br>";
> }
> };
>
>
> Chris Fry
>
> Tim Ward wrote:
>
> > according to the online refernce foreach() doesn't change
> the array pointer.
> > However the following code:
> >
> > $fred = array(1,2,3,4,5,6);
> > foreach ($fred as $fred1)
> > { foreach ($fred as $fred2)
> > echo "$fred1 : $fred2<br>";
> > };
> >
> > returns:
> >
> > 1 : 1
> > 1 : 2
> > 1 : 3
> > 1 : 4
> > 1 : 5
> > 1 : 6
> >
> > and stops there, implying that the second foreach() is
> interfering with the
> > first.
> >
> > I've got around this in my actual case by creating two
> arrays and adding to
> > the second as well as the first, but this won't always be
> as convenient. Is
> > this a known bug or is the manual wrong?
> >
> > ... by the way
> >
> > $fred = array(1,2,3,4,5,6);
> > $fred2 = $fred;
> > foreach ($fred as $fred1)
> > { foreach ($fred2 as $fred2)
> > echo "$fred1 : $fred2<br>";
> > };
> >
> > ... doesn't work either which would normally imply that
> $fred2 is a pointer
> > to $fred rather than a copy. Can this be the case?
> >
> > I am using version 4.0.0
> >
> > Tim Ward
> > Senior Systems Engineer
> >
> > Please refer to the following disclaimer in respect of this message:
> > http://www.stivesdirect.com/e-mail-disclaimer.html
> >
> > --
> > 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]
>
> --
> Chris Fry
> Quillsoft Pty Ltd
> Specialists in Secure Internet Services and E-Commerce Solutions
> 10 Gray Street
> Kogarah
> NSW 2217
> Australia
>
> Phone: +61 2 9553 1691
> Fax: +61 2 9553 1692
> Mobile: 0419 414 323
> eMail: [EMAIL PROTECTED]
> http://www.quillsoft.com.au
>
> You can download our Public CA Certificate from:-
> https://ca.secureanywhere.com/htdocs/cacert.crt
>
> **********************************************************************
>
> This information contains confidential information intended only for
> the use of the authorised recipient. If you are not an authorised
> recipient of this e-mail, please contact Quillsoft Pty Ltd by return
> e-mail.
> In this case, you should not read, print, re-transmit, store or act
> in reliance on this e-mail or any attachments, and should destroy all
> copies of them.
> This e-mail and any attachments may also contain copyright material
> belonging to Quillsoft Pty Ltd.
> The views expressed in this e-mail or attachments are the views of
> the author and not the views of Quillsoft Pty Ltd.
> You should only deal with the material contained in this e-mail if
> you are authorised to do so.
>
> This notice should not be removed.
>
>
--
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]