rand() and switch() combination
Posted: Sat Feb 16, 2008 5:40 am
Hey, I'm currently playing around with the following function:
The problem is that I need to make sure that $tag1, $tag2 and $tag3 can't take on the same cases in the switch argument. That is; $tag1, $tag2 and $tag3 should each have a distinct case from the switch function. How would I do this most efficient?
Code: Select all
function tagger(){
$rand = rand(1,5);
$int = rand(10,30);
$types = "SISP";
switch($rand){
case 1: $tag = "DINC:$types:PERC:$int"; break;
case 2: $tag = "DSDEC:$types:PERC:$int"; break;
case 3: $tag = "CHAD:$types:PERC:$int"; break;
case 4: $tag = "REFL:$types:PERC:$int"; break;
case 5: $tag = "DSTA:$types:PERC:$int"; break;
}
return $tag;
}
$tag1 = tagger();
$tag2 = tagger();
$tag3 = tagger();