Reply to Re: can you foreach() two arrays at once ?

Your name:

Reply:


Posted by J. Frank Parnell on 09/07/07 21:40

On Fri, 07 Sep 2007 15:01:24 -0400, Jerry Stuckle <jstucklex@attglobal.net>
wrote:

>Jerry Stuckle wrote:
>> J. Frank Parnell wrote:
>>> On Fri, 07 Sep 2007 07:22:46 -0400, Jerry Stuckle
>>> <jstucklex@attglobal.net>
>>> wrote:
>>>
>>>> J. Frank Parnell wrote:
>>>>> On Thu, 06 Sep 2007 21:41:27 -0400, Jerry Stuckle
>>>>> <jstucklex@attglobal.net>
>>>>> wrote:
>>>>>
>>>>>> J. Frank Parnell wrote:
>>>>>>> Hello,
>>>
>> reset $array1;
>> reset $array2;
>>
>> for (($val1 = each($array1)) || ($val2 = each($array2)) {
>> if ($val1) { // false if at the end
>> // $val1['key'] contains the key
>> // $val1['value'] contains the value
>> echo $val1['key'] . '=>' $val1['value'];
>> }
>> else
>> echo '&nbsp;';
>> if ($val2) { // false if at the end
>> // $val2['key'] contains the key
>> // $val2['value'] contains the value
>> echo $val2['key'] . '=>' $val2['value'];
>> }
>> else
>> echo '&nbsp;';
>> }
>>
>>
>
>Sorry - that should be:
>
>for (($val1 = each($array1)) || ($val2 = each($array2))) {
>
>Missed an extra paren at the end.

Thanks again for the help, however, I still get:
Parse error: syntax error, unexpected ')', expecting ';' in
/web/sites/asdf/asdf.com/_impexp/test.php on line 55

Isnt there supposed to be 3 expressions in a FOR? I tried with semicolons here
and there, but couldnt get it.

current code:
for (($val1 = each($users)) || ($val2 = each($newusers))) {
if ($val1) { // false if at the end
// $val1['key'] contains the key
// $val1['value'] contains the value
echo $val1['key'] . '=>' $val1['value'];
}
else
echo '&nbsp;';
if ($val2) { // false if at the end
// $val2['key'] contains the key
// $val2['value'] contains the value
echo $val2['key'] . '=>' $val2['value'];
}
else
echo '&nbsp;';
}

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация