By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

Nesting a Foreach Loop inside a For Loop

P: 12
Hi ! How to write foreach loop within for loop in php.Plz anybody know the answer reply me.Is it possible? Thanks.

[Bold is for emphasis (and mod comments), not for your entire post content. Thanks! --pbmods]
May 23 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 5,821
Changed thread title to better match contents.

Have you tried nesting the loops? It works.

Expand|Select|Wrap|Line Numbers
  1. for($i = -1; $i < somenumber; ++$i)
  2.     foreach($someArray[$i] as $idx => $val)
  3.         doSomething($val);
May 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.