switch php
snippet in php

switch php

user4794

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

user1710

$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;
}

case statement in php

user2805


<?php
switch ($i) {
    case "apple":
        echo "i is apple";
        break;
    case "bar":
        echo "i is bar";
        break;
    case "cake":
        echo "i is cake";
        break;
}
?>

php switich

user1934

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

user962


 <?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!";

 }

 ?>
 

switch php

user5451

switch ($i) {
    case 0:
        echo "i equals 0";
        break;
    case 1:
        echo "i equals 1";
        break;
    case 2:
        echo "i equals 2";
        break;
    default:
       echo "i is not equal to 0, 1 or 2";
}