ballhogjoni Posted March 19, 2011 Share Posted March 19, 2011 How do I skip to the next index in a foreach loop? I've tried the following: foreach($c as $val){ if(1==1){ next; } echo "HI" } In the code above it still echos HI How do I fix this? Quote Link to comment https://forums.phpfreaks.com/topic/231103-skip-to-next-index-in-a-foreach-loop/ Share on other sites More sharing options...
Pikachu2000 Posted March 19, 2011 Share Posted March 19, 2011 There is no 'next', and if you had error reporting on you'd be getting 'undefined constant' warnings regarding that. Use 'continue'. Quote Link to comment https://forums.phpfreaks.com/topic/231103-skip-to-next-index-in-a-foreach-loop/#findComment-1189588 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.