multiple cases for switch construct


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. switch (value)
  2.  
  3. {
  4.  
  5. case 1:
  6.  
  7. echo "Value was 1";
  8.  
  9. break;
  10.  
  11. case 2:
  12.  
  13. case 3:
  14.  
  15. echo "Value was 2 or 3";
  16.  
  17. break;
  18.  
  19. case 4:
  20.  
  21. echo "Value was 4";
  22.  
  23. break;
  24.  
  25. default:
  26.  
  27. echo "Value was not 1-4";
  28.  
  29. break;
  30.  
  31. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.