php case switch
snippet in php

switch php

user1450

switch ($element) {
    case 0:
        echo "i es igual a 0";
        break;
    case 1:
        echo "i es igual a 1";
        break;
    case 2:
        echo "i es igual a 2";
        break;
}

php switch

user9857

$age=20;
switch ($age) {
	case 19:
        echo "Age is 18";
        break;
    case 20:
        echo "Age is 20";
        break;
    case 21:
        echo "Age is 21";
        break;
}

switch case php

user4774

switch (fruit) {
  case apple:
    code to be executed if fruit=apple;
    break;
  case banana:
    code to be executed if fruit=banana;
    break;
    ...
  default:
    code to be executed if fruit is different from all fruits;
}

php case switch

user7973

switch ($i) {
    case 0:
        echo "i ist gleich 0";
        break;
    case 1:
        echo "i ist gleich 1";
        break;
    case 2:
        echo "i ist gleich 2";
        break;
}

php switich

user7654

switch (n) {
    case label1:
        code to be executed if n=label1;
        break;
    case label2:
        code to be executed if n=label2;
        break;
    case label3:
        code to be executed if n=label3;
        break;
    ...
    default:
        code to be executed if n is different from all labels;
} 

php switch

user9918


 <?php

 $favcolor = "red";


 switch ($favcolor)
 {

   case "red":

      echo "Your favorite color is red!";

      break;

  
 case "blue":

      echo "Your favorite color is blue!";

      break;

  
 case "green":

     echo "Your favorite color is green!";

    
 break;

  
 default:

      echo "Your favorite color is neither red, blue, nor green!";

 }

 ?>