You are here: Re: using two arrays in a 'for each ..." statement « PHP Language « IT news, forums, messages
Re: using two arrays in a 'for each ..." statement

Posted by C. on 11/03/07 17:25

On 3 Nov, 15:15, "mantrid" <ian.dan...@virgin.net> wrote:
> Hello
> I wish to extract two arrays and use them simultaneously in a for each
> statement
> Ive tried
> 'foreach ($yearsarray as &$yearvalue, $percentarray as &$percentvalue) {'
> and also
> 'foreach ($yearsarray as &$yearvalue AND $percentarray as &$percentvalue) {'
>

If each entry in one array matches one in the other then:

foreach ($yeararray as $index=>$year) {
print $year, $percentarray[$index];
}

Even if these were not compound data structures (as indicated in the
remainder of your code) your data design is a mess; both values
should be held in the same record in the same array.

C.

 

Navigation:

[Reply to this 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

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