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 #184061 is a reply to message #184047] Wed, 04 December 2013 01:30 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 12/3/2013 4:23 PM, Scott Johnson wrote:
> 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(at)example(dot)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

Ah, you're right, Scotty. I was looking at the last part of his code,
figuring it was similar to the first part. With Richard, I should have
known better.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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: Mon Oct 28 13:12:13 GMT 2024

Total time taken to generate the page: 0.05730 seconds