ballhogjoni Posted July 24, 2008 Share Posted July 24, 2008 how would you stop a foreach loop in the middle of the loop? My thoughts are having an if statement like: foreach() { $a = 1+4; if($a!=5){ break; } } Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted July 24, 2008 Share Posted July 24, 2008 chg the condition as below.. foreach() { $a = 1+4; if($a>=5){ break; } } Quote Link to comment Share on other sites More sharing options...
JonnyThunder Posted July 24, 2008 Share Posted July 24, 2008 It's better programming practice to control the loop, rather than to break out of it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.