Thread: goto
View Single Post
  #12  
Old 02-02-2008, 08:48 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by projectigi View Post
PHP Code:
for( foo 0foo 100foo++ )
  {
  for( 
bar  0bar 100bar++ )
    {
    
mehfoo ][ bar ] = blub;
    if( 
/* do something that would exit the loop */ )
      goto( 
lEndL01 );
    }
  }
Label lEndL01:
//after loop 
you don't always want to end the whole function :P
Then structure your code better.

You could easily have those two loops in a function by themselves, and use "return" to end there, and send back the result of your function execution to the calling function.
Reply With Quote