Questions tagged [break]

A break statement is a flow-control feature provided by most programming languages that allows for an early exit from a loop; once a break statement is reached, its enclosing loop is immediately exited.

Using break will immediately exit the loop without completing the current iteration, in this example when i is 3 the loop will finish without any other line in the loop being executed.

Example (Python):

for i in range(1, 6):
    print(i)
    if i == 3:
        break
    print("do stuff")
print("after the loop")

Output:

1
do stuff
2
do stuff
3
after the loop

For more information see

2598 questions
22
votes
6 answers

Line break on mobile phone only

I have a phone number on a website. It looks good on a laptop, but on a mobile device half of the number jumps to the next line. It doesn't look good. So how can I create a line break that will only work on a mobile device sized screen? I am not…
Henrik
  • 229
  • 1
  • 3
  • 7
22
votes
1 answer

PHP: Breaks in default case switches?

switch ($var) { case 0: // Do something... break; case 1: // Do something... break; default: // Do something... break; } I've seen some people use break at the end of the default case.…
user1307016
  • 383
  • 1
  • 8
  • 17
20
votes
1 answer

Why does VS and Windbg print "this" pointer as "0xcccccccc" even in debug version?

I tried to use windbg to print "this" pointer when entering a member function, like below. class IBase { int m_i; public: IBase() :m_i(23) {} virtual int FuncOne(void) = 0; virtual int FuncTwo(void) = 0; }; class DerivedOne : public…
Troskyvs
  • 7,537
  • 7
  • 47
  • 115
20
votes
3 answers

Swift 2 - Use case for using break on if statement?

Swift 2's guide mentions that you can end program execution of an if statement. I personally have never used break with if-statement. A break statement ends program execution of a loop, an if statement, or a switch statement...When a break…
Boon
  • 40,656
  • 60
  • 209
  • 315
20
votes
9 answers

Line Break in XML?

I'm a beginner in web development, and I'm trying to insert line breaks in my XML file. This is what my XML looks like: Song Title Lyrics Song…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/html" class="post-tag grid--cell" title="show questions tagged 'html'" rel="tag">html</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/parsing" class="post-tag grid--cell" title="show questions tagged 'parsing'" rel="tag">parsing</a> <a href="../../questions/tagged/line" class="post-tag grid--cell" title="show questions tagged 'line'" rel="tag">line</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 06 '10 at 23:07">asked Jun 06 '10 at 23:07</time> <a href="../../users/359939/ew89" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/359939.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="ew89" /> </a> <div class="s-user-card--info"> <a href="../../users/359939/ew89" class="s-user-card--link">ew89</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">203</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="2 silver badge">2</li> <li class="s-award-bling s-award-bling__bronze" title="6 bronze badge">6</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-5118965"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>19</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>6</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/5118965/what-the-difference-between-break-with-label-and-without-label-in-javascript" class="question-hyperlink">what the difference between break with label and without label in javascript</a></h3> <div class="excerpt"> var num = 0; for(var i = 0; i < 10; i++){ for(var j = 0; j < 10 ; j++){ if(i == 5 && j == 5){ break; } num++; } } console.log(num) In the above code, I expect the result to be 55 but why the result is 95. But why…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/label" class="post-tag grid--cell" title="show questions tagged 'label'" rel="tag">label</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Feb 25 '11 at 15:20">asked Feb 25 '11 at 15:20</time> <a href="../../users/551404/dramasea" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/551404.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="dramasea" /> </a> <div class="s-user-card--info"> <a href="../../users/551404/dramasea" class="s-user-card--link">dramasea</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">3,370</li> <li class="s-award-bling s-award-bling__gold" title="16 gold badges">16</li> <li class="s-award-bling s-award-bling__silver" title="49 silver badges">49</li> <li class="s-award-bling s-award-bling__bronze" title="77 bronze badges">77</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-4278532"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>19</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/4278532/how-to-stop-gdb-from-executing-break-main-by-default-in-eclipse" class="question-hyperlink">How to stop GDB from executing "break main" by default in Eclipse?</a></h3> <div class="excerpt">I'm working on a C project with Eclipse and MinGW. When running a debug build of this project, gdb always breaks on entering main(). I can see why this could be useful, but for my current project I don't want that to happen. I've read that there is…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c" class="post-tag grid--cell" title="show questions tagged 'c'" rel="tag">c</a> <a href="../../questions/tagged/eclipse" class="post-tag grid--cell" title="show questions tagged 'eclipse'" rel="tag">eclipse</a> <a href="../../questions/tagged/gdb" class="post-tag grid--cell" title="show questions tagged 'gdb'" rel="tag">gdb</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Nov 25 '10 at 15:19">asked Nov 25 '10 at 15:19</time> <a href="../../users/390562/timo" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/390562.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Timo" /> </a> <div class="s-user-card--info"> <a href="../../users/390562/timo" class="s-user-card--link">Timo</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">2,212</li> <li class="s-award-bling s-award-bling__gold" title="2 gold badges">2</li> <li class="s-award-bling s-award-bling__silver" title="25 silver badges">25</li> <li class="s-award-bling s-award-bling__bronze" title="46 bronze badges">46</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-3823112"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>19</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/3823112/how-to-break-words-into-syllables-in-latex-correctly" class="question-hyperlink">How to break words into syllables in LaTeX correctly</a></h3> <div class="excerpt">I am writing my MSc with LaTeX and I have the problem that sometimes my words are divided in a wrong way. My language is spanish and I'm using babel package. How could I solve it? For example: propuestos appears prop-uestos (uestos in next line). It…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/package" class="post-tag grid--cell" title="show questions tagged 'package'" rel="tag">package</a> <a href="../../questions/tagged/latex" class="post-tag grid--cell" title="show questions tagged 'latex'" rel="tag">latex</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> <a href="../../questions/tagged/text-segmentation" class="post-tag grid--cell" title="show questions tagged 'text-segmentation'" rel="tag">text-segmentation</a> <a href="../../questions/tagged/lexical" class="post-tag grid--cell" title="show questions tagged 'lexical'" rel="tag">lexical</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 29 '10 at 15:29">asked Sep 29 '10 at 15:29</time> <a href="../../users/372895/legami" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/372895.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="legami" /> </a> <div class="s-user-card--info"> <a href="../../users/372895/legami" class="s-user-card--link">legami</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,303</li> <li class="s-award-bling s-award-bling__gold" title="6 gold badges">6</li> <li class="s-award-bling s-award-bling__silver" title="22 silver badges">22</li> <li class="s-award-bling s-award-bling__bronze" title="31 bronze badges">31</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-3145563"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>19</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>7</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/3145563/list-foreach-break" class="question-hyperlink">List ForEach break</a></h3> <div class="excerpt">is there a way to break out of the foreach extension method? The "break" keyword doesn't recognize the extension method as a valid scope to break from. //Doesn't compile Enumerable.Range(0, 10).ToList().ForEach(i => {…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c#" class="post-tag grid--cell" title="show questions tagged 'c#'" rel="tag">c#</a> <a href="../../questions/tagged/foreach" class="post-tag grid--cell" title="show questions tagged 'foreach'" rel="tag">foreach</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 29 '10 at 23:40">asked Jun 29 '10 at 23:40</time> <a href="../../users/124034/tbischel" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/124034.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="tbischel" /> </a> <div class="s-user-card--info"> <a href="../../users/124034/tbischel" class="s-user-card--link">tbischel</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">6,337</li> <li class="s-award-bling s-award-bling__gold" title="11 gold badges">11</li> <li class="s-award-bling s-award-bling__silver" title="51 silver badges">51</li> <li class="s-award-bling s-award-bling__bronze" title="73 bronze badges">73</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-11324156"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>19</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/11324156/prevent-xdebug-to-break-at-first-line-of-index-file" class="question-hyperlink">Prevent xdebug to break at first line of index file</a></h3> <div class="excerpt">I have xdebug setup with Eclipse PDT. Every time I start a debug session, Eclipse breaks at the first line of my root index.php file. Is it possible to prevent this behavior? </div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/php" class="post-tag grid--cell" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/eclipse" class="post-tag grid--cell" title="show questions tagged 'eclipse'" rel="tag">eclipse</a> <a href="../../questions/tagged/xdebug" class="post-tag grid--cell" title="show questions tagged 'xdebug'" rel="tag">xdebug</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> <a href="../../questions/tagged/eclipse-pdt" class="post-tag grid--cell" title="show questions tagged 'eclipse-pdt'" rel="tag">eclipse-pdt</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jul 04 '12 at 07:15">asked Jul 04 '12 at 07:15</time> <a href="../../users/561309/laurent" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/561309.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="laurent" /> </a> <div class="s-user-card--info"> <a href="../../users/561309/laurent" class="s-user-card--link">laurent</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">88,262</li> <li class="s-award-bling s-award-bling__gold" title="77 gold badges">77</li> <li class="s-award-bling s-award-bling__silver" title="290 silver badges">290</li> <li class="s-award-bling s-award-bling__bronze" title="428 bronze badges">428</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-4332345"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>18</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>10</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/4332345/break-in-nested-for-loops" class="question-hyperlink">Break in nested for loops</a></h3> <div class="excerpt"> Possible Duplicate: How to Break from main/outer loop in a double/nested loop? I have the following situation: for(int i = 0; i < schiffe.length-1; i++){ if(schiffe[i].schaden){ schlepper.fliege(schiffe[i].x, …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/loops" class="post-tag grid--cell" title="show questions tagged 'loops'" rel="tag">loops</a> <a href="../../questions/tagged/for-loop" class="post-tag grid--cell" title="show questions tagged 'for-loop'" rel="tag">for-loop</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> <a href="../../questions/tagged/labelled-break" class="post-tag grid--cell" title="show questions tagged 'labelled-break'" rel="tag">labelled-break</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 02 '10 at 06:36">asked Dec 02 '10 at 06:36</time> <a href="../../users/401025/darkleafygreen" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/401025.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="DarkLeafyGreen" /> </a> <div class="s-user-card--info"> <a href="../../users/401025/darkleafygreen" class="s-user-card--link">DarkLeafyGreen</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">69,338</li> <li class="s-award-bling s-award-bling__gold" title="131 gold badges">131</li> <li class="s-award-bling s-award-bling__silver" title="383 silver badges">383</li> <li class="s-award-bling s-award-bling__bronze" title="601 bronze badges">601</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-4475464"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>17</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/4475464/how-do-i-allow-breaking-on-system-nullreferenceexception-in-vs2010" class="question-hyperlink">How do I allow breaking on 'System.NullReferenceException' in VS2010?</a></h3> <div class="excerpt">I have a VS 2010 C# .NET 4 project. The issue is that the program is not breaking on 'NullReferenceException' errors during debugging. The output window will display the following: A first chance exception of type 'System.NullReferenceException'…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c#" class="post-tag grid--cell" title="show questions tagged 'c#'" rel="tag">c#</a> <a href="../../questions/tagged/debugging" class="post-tag grid--cell" title="show questions tagged 'debugging'" rel="tag">debugging</a> <a href="../../questions/tagged/visual-studio-2010" class="post-tag grid--cell" title="show questions tagged 'visual-studio-2010'" rel="tag">visual-studio-2010</a> <a href="../../questions/tagged/nullreferenceexception" class="post-tag grid--cell" title="show questions tagged 'nullreferenceexception'" rel="tag">nullreferenceexception</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 17 '10 at 22:54">asked Dec 17 '10 at 22:54</time> <a href="../../users/273723/mike-webb" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/273723.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Mike Webb" /> </a> <div class="s-user-card--info"> <a href="../../users/273723/mike-webb" class="s-user-card--link">Mike Webb</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">8,855</li> <li class="s-award-bling s-award-bling__gold" title="18 gold badges">18</li> <li class="s-award-bling s-award-bling__silver" title="78 silver badges">78</li> <li class="s-award-bling s-award-bling__bronze" title="111 bronze badges">111</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-37814942"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>17</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>5</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/37814942/early-breaking-from-rust-s-match" class="question-hyperlink">Early-breaking from Rust's match</a></h3> <div class="excerpt">I want to switch through many possible cases for x and there's one case (here x == 0) where I want to check the result of some additional code to determine what to do next. One possibility is to return early from the match. I'd use break to do this…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/pattern-matching" class="post-tag grid--cell" title="show questions tagged 'pattern-matching'" rel="tag">pattern-matching</a> <a href="../../questions/tagged/rust" class="post-tag grid--cell" title="show questions tagged 'rust'" rel="tag">rust</a> <a href="../../questions/tagged/match" class="post-tag grid--cell" title="show questions tagged 'match'" rel="tag">match</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 14 '16 at 14:30">asked Jun 14 '16 at 14:30</time> <a href="../../users/4453524/ljrk" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/4453524.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="ljrk" /> </a> <div class="s-user-card--info"> <a href="../../users/4453524/ljrk" class="s-user-card--link">ljrk</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">751</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="5 silver badge">5</li> <li class="s-award-bling s-award-bling__bronze" title="21 bronze badge">21</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-1586932"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>17</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>14</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/1586932/what-is-a-neat-way-of-breaking-out-of-many-for-loops-at-once" class="question-hyperlink">What is a neat way of breaking out of many for loops at once?</a></h3> <div class="excerpt">Suppose I need to break out of three or four nested for loops at once at the occurence of some event inside the innermost loop. What is a neat way of doing that? what I do is use flags like this: int i, j, k; int flag1 = 0; int flag2 = 0; for (i =…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c" class="post-tag grid--cell" title="show questions tagged 'c'" rel="tag">c</a> <a href="../../questions/tagged/for-loop" class="post-tag grid--cell" title="show questions tagged 'for-loop'" rel="tag">for-loop</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Oct 19 '09 at 04:20">asked Oct 19 '09 at 04:20</time> <a href="../../users/182959/moeb" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/182959.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Moeb" /> </a> <div class="s-user-card--info"> <a href="../../users/182959/moeb" class="s-user-card--link">Moeb</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">10,527</li> <li class="s-award-bling s-award-bling__gold" title="31 gold badges">31</li> <li class="s-award-bling s-award-bling__silver" title="84 silver badges">84</li> <li class="s-award-bling s-award-bling__bronze" title="110 bronze badges">110</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-3647264"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>16</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>6</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/3647264/simple-for-loop-not-working" class="question-hyperlink">Simple for loop not working</a></h3> <div class="excerpt">I've just started learning programming. I'm studying for loops but this program does not work as expected. I want to break the loop when $a is equal to 3 so that I get the output 1 2 but I get 3 as output :( for($a=0;$a<10;++$a) { if($a==3) …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/php" class="post-tag grid--cell" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/syntax" class="post-tag grid--cell" title="show questions tagged 'syntax'" rel="tag">syntax</a> <a href="../../questions/tagged/loops" class="post-tag grid--cell" title="show questions tagged 'loops'" rel="tag">loops</a> <a href="../../questions/tagged/for-loop" class="post-tag grid--cell" title="show questions tagged 'for-loop'" rel="tag">for-loop</a> <a href="../../questions/tagged/break" class="post-tag grid--cell" title="show questions tagged 'break'" rel="tag">break</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 05 '10 at 18:40">asked Sep 05 '10 at 18:40</time> <a href="../../users/440148/user440148" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/440148.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="user440148" /> </a> <div class="s-user-card--info"> <a href="../../users/440148/user440148" class="s-user-card--link">user440148</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">161</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badges">1</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badges">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/break_page=6" rel="prev" title="Go to page 6">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/break_page=1" rel="" title="Go to page 1">1</a> <a class="s-pagination--item" href="../../questions/tagged/break_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/break_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/break_page=99" rel="" title="Go to page 99">99</a> <a class="s-pagination--item" href="../../questions/tagged/break_page=100" rel="" title="Go to page 100">100</a> <a class="s-pagination--item" href="../../questions/tagged/break_page=8" rel="next" title="Go to page 8"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>