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? 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'. 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
Archived
This topic is now archived and is closed to further replies.