mardi 24 mars 2015

Choose random code within switch statement

I'm using a switch statement with several cases.


When one of the cases is chosen, how can I randomly choose a block of code within that case, but without using a nested switch statement?


For example:



switch ($choose_case){

case 1:
//some code
break;

case 2:
//some code
break;

case 3:
(random block of code #1)
(random block of code #2)
=randomly choose #1 or #2
break;

}

Aucun commentaire:

Enregistrer un commentaire