How to break out of nested loops?

Discussion in 'CommandHelper' started by malon, Jan 21, 2018.

  1. malon

    malon Member

    PHP:
    for(@x = @loc[0] - @radius, @x <= @loc[0] + @radius, @x++) {
        for(@y = @loc[1] - @radius, @y <= @loc[1] + @radius, @y++) {
            for(@z = @loc[2] - @radius, @z <= @loc[2] + @radius, @z++) {
                @block = get_block_at(@x, @y, @z)
                if(@block != '0:0'){
                    @foundNonAirBlock = true
                    #break out of all loops
               }
            }
        }
    }
    Does commandhelper support goto or labels or some way to break out of nested loops? I can't seem to find anything

    edit: once again, as soon as I post I end up thinking of a workaround, set the loops as a procedure and then return() from it
    Last edited: Jan 21, 2018
  2. PseudoKnight

    PseudoKnight Well-Known Member Developer

    Yes, use break(3).