SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2002
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    break; a while() ?

    hey, is it possible to break; a while loop?

    if not, how can it be done?

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    >> hey, is it possible to break; a while loop?
    Yes,
    example:

    PHP Code:
    $i 0;
    while ( 
    ) {
       if ( 
    $i++ > ) {
          break; 
    // <<-- force the exit from the while loop
       
    }



    :-) Andrea
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2002
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pippo
    >> hey, is it possible to break; a while loop?
    Yes,
    example:
    PHP Code:
    $i 0;
    while ( 
    ) {
    if ( 
    $i++ > ) {
    break; 
    // <<-- force the exit from the while loop
    }

    :-) Andrea
    ah, thanks. i feel like an idiot. i didn't have another variable set right, and therefore didn't break; my while loop.

    but hey, gotta look stupid sometimes to find the answers!

    thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •