case statement in php
snippet in php

case statement in php

user150


<?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 switch

user2301


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

 }

 ?>