In a conversation earlier this week I was discussing certain language features, and I realized I don't have a good word / phrase to describe a particular feature.

Some languages, such as PHP, have a language construct which allows break and continue statements to accept a numeric parameter indicating which block should be affected. For example:

for ($i = 0; $i < 10; $i++)
    for ($j = 10; $j > 0; $j--)
        if ($j == $i) 
            break 2;
echo $i;

Because break 2; causes the outer loop to break, the output is 1. If this were break 1; or just break; the output would be 10.

C# does not have any such construct. The equivalent would something like this:

for (i = 0; i < 10; i++) {
    bool broken = false;
    for (j = 10; j > 0; j--) {
        if (j == i) {
            broken = true;
    if (broken)

But of course, this could also be accomplished using a goto.

So my question is, what do you call this? Is there a specific name for this "break n" construct? I'd like to be able to say "Language X has parametric break and continue statements", or something like that.

  • 1
    With php 5.4, the option for this to be a variable was removed. Its no different than a label break in that respect now - just different syntax. Label break is available in all languages that I am familiar with that have a break statement.
    – user40980
    Commented Feb 6, 2014 at 20:26
  • @MichaelT Hmm, I wasn't familiar with the "label-break" until you mentioned it. It seems Java supports it (demo), but not C#.
    – p.s.w.g
    Commented Feb 6, 2014 at 20:32
  • C# does have a goto that can be used to skip out of nested loops - see Breaking out of a nested loop (and its not a language I'm familiar with)
    – user40980
    Commented Feb 6, 2014 at 20:34
  • 4
    I find break with a label name (where the label is, ideally, the name of the loop) to be much clearer than break 2. Having the computer require a human to count something is absurd. Commented Feb 6, 2014 at 20:48
  • 1
    @RobertHarvey I know it's rare, but PHP is not the only one. After some quick Googling I found this and this, and I seem to remember seeing it elsewhere, too.
    – p.s.w.g
    Commented Feb 6, 2014 at 22:45

1 Answer 1


Java has this and it is called a "labelled break" from what I've seen.

From Oracle's Java Tutorial on Branching Statements:

The break statement has two forms: labeled and unlabeled. ... An unlabeled break statement terminates the innermost switch, for, while, or do-while statement, but a labeled break terminates an outer statement.

In your PHP example it's not really "labelled" per-se (although you could consider the 2 an implicit label) but more like a "relative" or "nested" break. Any of those adjectives should work.

PS - I'm surprised C# didn't steal that from Java since they took just about everything else.

  • C# took only the good things from Java ;-)
    – Doc Brown
    Commented Dec 10, 2014 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.