PHP switch AND break

Though switch and break statements have lots of explanation scattered all around the net but there are few concepts which we rarely use. One such thing which I came across today is to use a conditional statement in case. The general syntax for switch is

switch($n) {
    case 1: echo 1; break;
    case 2: echo 2; break;
    default: echo 'No conditions satisfied'; break;
}

The below syntax is not well known to new programmers i.e. to print messages if n is between 2 different values

switch($n) {
    case ($n>=1 && $n<=2): echo $n." is between 1 and 2"; break;
    case ($n>=3 && $n<=4): echo $n." is between 3 and 4"; break;
    default: echo "No conditions satisfied"; break;
}

Similarly break is used to come out of the loop. For example

for ($i=0; $i<10; $i++) {
    //code to be executed
    if($i == 5) break;
}

//rest code will execute 

The code here gets executed till $i becomes 5 after which the for loop execution will stop. Now what if we want to break out of nested loops. The lesser known syntax is break n where n is the loop number. For example

for ($j=0; $j<20; $j++) {
  for ($i=0; $i<10; $i++) {
	//code to be executed
	if ($i == 5) break 2;
  }
}
//rest code will execute

Here 2 means it will stop execution for the outer $j loop. The loop number counting starts from the loop where the break is called and increases by 1 for its parent loop.