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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

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

Post 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.
Last edited by vinoth on Wed Aug 29, 2007 1:40 am, edited 1 time in total.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post 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();
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

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

Post by volka »

vinoth wrote:I also need any other alternatiive solution regarding this
this requires more information.
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post by vinoth »

hope array_merge will do this

Thanks for the suggestion
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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).
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post by vinoth »

Hi scottayy

Its Working fine
Thanks for All your suggestions & Guidelines.
Post Reply