Bruce Gust
asked on
How would I write a for loop within a for loop and get this result?
Here's the tongue twister:
I'm doing a for loop and I get this result:
Florida
Louisiana
Texas
Kentucky
What I need to do is go through that for loop and WITHIN that same cycle do something like this:
First, here's my starting point:
foreach($page_display as $page)
{
//normal listing of results like what you see
}
Now, here's what I need to do:
foreach($page_display as $page)
{
foreach($page_display as $page)
{
if($current_state <> $page['state']
{
//here I need to create a list of every state EXCEPT the one, so, in this scenario, I need four different recordsets:
#1
Louisiana
Texas
Kentucky
#2
Florida
Texas
Kentucky
#3
Florida
Louisiana
Kentucky
#4
Florida
Louisiana
Texas
}
}
}
How would I do this?
I'm doing a for loop and I get this result:
Florida
Louisiana
Texas
Kentucky
What I need to do is go through that for loop and WITHIN that same cycle do something like this:
First, here's my starting point:
foreach($page_display as $page)
{
//normal listing of results like what you see
}
Now, here's what I need to do:
foreach($page_display as $page)
{
foreach($page_display as $page)
{
if($current_state <> $page['state']
{
//here I need to create a list of every state EXCEPT the one, so, in this scenario, I need four different recordsets:
#1
Louisiana
Texas
Kentucky
#2
Florida
Texas
Kentucky
#3
Florida
Louisiana
Kentucky
#4
Florida
Louisiana
Texas
}
}
}
How would I do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.