Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #12099
| From | Scott Johnson <noonehome@chalupasworld.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: foreach as list |
| Date | 2013-12-03 13:23 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <l7li3p$9b5$1@dont-email.me> (permalink) |
| References | <1lb2ueqjc0qju.xhszpol7p3t4.dlg@40tude.net> <h8cs991jviohi5s462tvibjs3etmouf1u1@4ax.com> <l7lc2q$20p$1@dont-email.me> |
On 12/3/2013 11:40 AM, Jerry Stuckle wrote:
> On 12/3/2013 2:30 PM, Richard Yates wrote:
>> On Tue, 3 Dec 2013 10:10:59 -0500, richard <noreply@example.com>
>> wrote:
>>
>>> 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 '$
>>>
>>> Their example:
>>>
>>> <?php
>>> $array = [
>>> [1, 2],
>>> [3, 4],
>>> ];
>>>
>>> foreach ($array as list($a)) {
>>> // Note that there is no $b here.
>>> echo "$a\n";
>>> }
>>> ?>
>>>
>>> The above example will output:
>>>
>>> 1
>>> 3
>>
>> echo $a"\n"; [needs a dot.]
>>
>
> Actually, in the case, richard is correct (for this line of code,
> anyway). Simple variables within double quotes are evaluated.
>
However as typical for richard he mistyped his code compared to the sample.
Sample: "$a\n"
Richards: $a"\n"
Scotty
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
foreach as list richard <noreply@example.com> - 2013-12-03 10:10 -0500
Re: foreach as list Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-03 16:18 +0100
Re: foreach as list richard <noreply@example.com> - 2013-12-03 10:16 -0500
Re: foreach as list Richard Yates <richard@yatesguitar.com> - 2013-12-03 11:30 -0800
Re: foreach as list Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-03 14:40 -0500
Re: foreach as list Scott Johnson <noonehome@chalupasworld.com> - 2013-12-03 13:23 -0800
Re: foreach as list Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-03 20:30 -0500
Re: foreach as list Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-12-04 00:48 +0000
csiph-web