<?
$teams = array();
$c = "";
for($a=0;$a<9;$a++) {
$b = rand(1,8);
$cr = "team".$b;
if(array_key_exists($cr,$teams)) {
$a--; // if exists step back and continue loop
} else {
$teams[$cr] = "";
if(count($teams) == 8) {
$a += 1000; // break loop
}
}
}
$a = 0;
while (list($key) = each($teams)) {
echo "$key \n";
if(fmod($a,2) == 0 || $a== 0 ) {
echo " vs ";
} else {
echo "<br>";
}
$a++;
}
?>