Jump to content

[SOLVED] break not working to exit logic FOR loop


drumhrd

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.