Return to Snippet

Revision: 3376
at July 18, 2007 06:25 by valcartei


Initial Code
switch (value)
  
          {
 
          case 1:
 
              echo "Value was 1";
  
              break;
  
          case 2:
   
          case 3:
  
              echo "Value was 2 or 3";
  
              break;

          case 4: 

              echo "Value was 4";
 
              break;

          default:   
  
              echo "Value was not 1-4";
  
              break;
  
          }

Initial URL
http://www.nutt.net/2004/12/28/multiple-cases-for-switch-construct/

Initial Description
put case value1:case value2:case value3: to allow the same code be executed when the value passed equals value1 or value2 or value3.

Initial Title
multiple cases for switch construct

Initial Tags

                                

Initial Language
PHP