drumhrd Posted September 13, 2009 Share Posted September 13, 2009 hello..can someone tell me why this is not working for($r = 1; $r < $_SESSION['lineitem']; $r++){ $showrandom = 0; if (isset($_SESSION['ITEM_'.$r]) == FALSE){ $showrandom = 1; break 2; } } I am getting the following error Fatal error: Cannot break/continue 2 levels in /var/www/s/cart.php on line 108 I thought the number meant how many logic blocks to break. I want to exit out of the for loop and continue with my code. Quote Link to comment https://forums.phpfreaks.com/topic/174125-solved-break-not-working-to-exit-logic-for-loop/ Share on other sites More sharing options...
mikesta707 Posted September 13, 2009 Share Posted September 13, 2009 break breaks out of a loop, so you only need to break 1; you can't break out of an if statement Quote Link to comment https://forums.phpfreaks.com/topic/174125-solved-break-not-working-to-exit-logic-for-loop/#findComment-917865 Share on other sites More sharing options...
drumhrd Posted September 14, 2009 Author Share Posted September 14, 2009 yes yes..I see..I feel stupid...thanks for the help!!! Quote Link to comment https://forums.phpfreaks.com/topic/174125-solved-break-not-working-to-exit-logic-for-loop/#findComment-918097 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.