×

Welcome to TagMyCode

Please login or create account to add a snippet.
2
0
 
0
Language: PHP
Posted by: jaid int
Added: Dec 14, 2016 3:59 PM
Modified: Dec 14, 2016 4:06 PM
Views: 18
  1. switch ($i):
  2.     case 0:
  3.         echo "i equals 0";
  4.         break;
  5.     case 1:
  6.         echo "i equals 1";
  7.         break;
  8.     case 2:
  9.         echo "i equals 2";
  10.         break;
  11.     default:
  12.         echo "i is not equal to 0, 1 or 2";
  13. endswitch;
  14.  
  15.  
  16. switch ($i) {
  17. case 0:
  18. case 1:
  19. case 2:
  20.     echo "i is less than 3 but not negative";
  21.     break;
  22. case 3:
  23.     echo "i is 3";
  24. }
  25.  
  26. switch($beer)
  27. {
  28.     case 'tuborg';
  29.     case 'carlsberg';
  30.     case 'heineken';
  31.         echo 'Good choice';
  32.     break;
  33.     default;
  34.         echo 'Please make a new selection...';
  35.     break;
  36. }