FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » foreach as list
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: foreach as list [message #184058 is a reply to message #184041] Wed, 04 December 2013 00:48 Go to previous message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma:
Senior Member
richard <noreply(at)example(dot)com> wrote in news:1lb2ueqjc0qju.xhszpol7p3t4.dlg@
40tude.net:

> foreach ($six0 as list($a,$b)){
> echo $a"\n";
> echo $b"\n";
>
> }
>
> http://us1.php.net/manual/en/control-structures.foreach.php
>
> Used as shown in the example, I get this:
> Parse error: syntax error, unexpected T_LIST, expecting '&' or T_STRING or
> T_VARIABLE or '$

No, you don't. If you get that, then you didn't use it as shown in the example.
>
> Their example:
>
> <?php
> $array = [
> [1, 2],
> [3, 4],
> ];
>
> foreach ($array as list($a)) {
> // Note that there is no $b here.

Which means that you didn't use it as shown in the example.

> echo "$a\n";
> }
> ?>
>
> The above example will output:
>
> 1
> 3
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: SEO SERVICES
Next Topic: Can I download file with address like this "http://***.com/file.php/ABC.html" automatically ?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 11:00:08 GMT 2024

Total time taken to generate the page: 0.04458 seconds