Jump to content

Recommended Posts

I have a switch that uses a rand() to find the respective cases in between a number range, like so:

 

switch($number = rand(1,10)) {
   case ($number > 1 && $number <= 5):
       doFunction();
   break;
   case ($number > 5):
       doFunction();
   break;
}

 

how would I use this in an array format? I find using switches to be clunky and limiting.

 

I want to be able to do like:

 

$array = array(
  1-10 => 'value',
  11-20 => 'value'
)

 

Is this possible?

Edited by Tidehunter

If you have an actual question, go ahead and ask it.  Your quick example was bad PHP code, and you haven't explained what you are trying to do.  There isn't a great way for us to help you if you don't describe a problem or provide actual code to look at.

If you have an actual question, go ahead and ask it. Your quick example was bad PHP code, and you haven't explained what you are trying to do. There isn't a great way for us to help you if you don't describe a problem or provide actual code to look at.

 

Actually I did. My question was, is there another way to use a number range using arrays. You're telling me how switches work, yet you don't provide an example. You're telling me to provide actual code to look when I don't even know how to code it? rofl

 

I wasn't looking forward to having an ass enter my thread, otherwise I'd just fart.

 

Thanks for your god damn help.

Guest
This topic is now 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.