Jump to content

Case Statement


EchoFool

Recommended Posts

Yes, you can use ANY kind of comparison in a CASE statement - you just have to be creative. Remember the case value must match the switch value. So, just use the boolean true for the switch value and the comparisons as the case value

 

Example

switch(true)
{
  case ($num>50 && $num<150):
    //action goes here
  break;

  case ($num>=150 && $num<300):
    //action goes here
  break;
}

Link to comment
https://forums.phpfreaks.com/topic/203105-case-statement/#findComment-1064280
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.