Please help.
for($i=0; $i<12; $i++ ){
switch($i) {
case 0:
case 1:
case 2:
case 3:
case 4:
echo ("i is less than 5 <br>");
break;
case 5:
case 6:
case 7:
case 8:
case 9:
echo ("i is less than 10 <br>");
break;
default:
echo ("i is 10 or more <br>");
}
}
This is the example code I got in my Java book and I translated the code above to PHP.
The output of the following code:
i is less than 5
i is less than 5
i is less than 5
i is less than 5
i is less than 5
i is less than 10
i is less than 10
i is less than 10
i is less than 10
i is less than 10
i is 10 or more
i is 10 or more
My question is that how come that case 0 to case 3 outputs "i is less than 5" even though it doesn't have any following code and case 4 is the one with echo statement? I'm confused, can someone explain this to me. Thanks in advance.