所以我做了这个功能,你可以随机选择一种颜色。问题是我要打印相同的函数 8 次,我不希望其中两个打印返回相同的变量。所以基本上我希望它在之前打印过颜色的情况下再次运行该功能。
function random_color(){
$color_numb = "8";
$color = rand(1, $color_numb);
if($color == "1"){
$type = "Blue";
}
if($color == "2"){
$type = "Red";
}
if($color == "3"){
$type = "Orange";
}
if($color == "4"){
$type = "Green";
}
if($color == "5"){
$type = "Yellow";
}
if($color == "6"){
$type = "Black";
}
if($color == "7"){
$type = "Purple";
}
if($color == "8"){
$type = "White";
}
return $type;
}
print random_color();
print random_color();
print random_color();
print random_color();
print random_color();
print random_color();
print random_color();
print random_color();
所以知道我怎么能做到这一点吗?