Page 1 of 1

[RESOLVED] Any way to execute 2 arrays in single for each()

Posted: Mon Aug 13, 2007 7:42 am
by vinoth
hi All

I am working with PHP for my current project..

In my project I have to execute two resultset values in one for loop
Is there any possible way to achieve this..

I also need any other alternatiive solution regarding this


Thanks in advance.

Posted: Mon Aug 13, 2007 8:05 am
by miro_igov
If the result sets are returned by mysql_query() function you cannot combine them but you can loop over and put them into 2 arrays then use array_merge();

Re: Any possible way to execute two arrays in single for eac

Posted: Mon Aug 13, 2007 8:05 am
by volka
vinoth wrote:I also need any other alternatiive solution regarding this
this requires more information.

Posted: Mon Aug 13, 2007 8:20 am
by vinoth
hope array_merge will do this

Thanks for the suggestion

Posted: Mon Aug 13, 2007 10:25 am
by s.dot
Doesn't sound to me like array_merge() will do the trick, as it will put both sets of data into one array. I'm not sure this is what you want?

You could loop through each result set and store them in separate container arrays. Then make your own loop and reference each array inside the loop.

Or, you could simply have a loop inside of another loop (i believe this is not the preferred way of doing it).

Posted: Wed Aug 29, 2007 1:39 am
by vinoth
Hi scottayy

Its Working fine
Thanks for All your suggestions & Guidelines.