Backstory: Long story short, this script is for a christmas secret santa drawing. 1 person will have to draw 3 names. I have 9 people that will be drawing. What i got so far is that it grabs 3 random names from the pool and assigns the names to each person. The thing i need help on is I only want each name to be drawn 3 times. Help?
This is the outcome:
Sia:
Sia
Kou
Dad
Stacie:
Apollo
Pahoua
Dad
Apollo:
Dad
Kou
Apollo
Kim:
Kim
Pahoua
Stacie
Pheng:
Kim
Sia
Pheng
Pahoua:
Pheng
Pahoua
Dad
Mom:
Stacie
Mom
Apollo
Dad:
Sia
Stacie
Kou
Kou:
Stacie
Apollo
Kou
Code:
$sia = "Sia";
$stacie = "Stacie";
$apollo = "Apollo";
$kim = "Kim";
$pheng = "Pheng";
$pahoua = "Pahoua";
$mom = "Mom";
$dad = "Dad";
$kou = "Kou";
$drawer = array($sia, $stacie, $apollo, $kim, $pheng, $pahoua, $mom, $dad, $kou);
$names = array($sia, $stacie, $apollo, $kim, $pheng, $pahoua, $mom, $dad, $kou);
foreach ($drawer as $picker)
{
echo $picker . ": <br/>";
shuffle($names); //shuffles the names
$shuffledname = array_rand($names, 3); //Only shows 3 random names that were shuffled
$name1 = $names[$shuffledname[0]];
$name2 = $names[$shuffledname[1]];
$name3 = $names[$shuffledname[2]];
echo $name1 . "<br />";
echo $name2 . "<br />";
echo $name3 . "<br /><br />";
}
This is the outcome:
Sia:
Sia
Kou
Dad
Stacie:
Apollo
Pahoua
Dad
Apollo:
Dad
Kou
Apollo
Kim:
Kim
Pahoua
Stacie
Pheng:
Kim
Sia
Pheng
Pahoua:
Pheng
Pahoua
Dad
Mom:
Stacie
Mom
Apollo
Dad:
Sia
Stacie
Kou
Kou:
Stacie
Apollo
Kou
