I have created a simple name randomizer for a game my school is playing. I need it to pick names at random. I have done so.
But now i run into a problem..
Once a pair of names has been picked- it cant re pick it..how would i do this?
index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Random Team/Name Pick</title>
</head>
<body>
To pick a random team with names, press the generate putton below.
<FORM>
<INPUT TYPE="button" onClick="parent.location='pick.php'" value="Generate">
</FORM>
</body>
</html>
pick.php
<?php
$file = "data.txt"; //defines $file to = data.txt
srand((double)microtime()*1000000);
if (file_exists($file)) { //if the file actually exists, call it
$arry_txt = preg_split("/--BREAK--/", join('', file($file))); //split the text file at every section if there is "--BREAK--" seperating
echo $arry_txt[rand(0, sizeof($arry_txt) -1)]; //display the section at random.
} else {
echo "Error: can't open $file"; //if the script cannot locate $file, echo (or display) the following error
} // for every "{" there needs to be an "}". Same goes for "(".
?>
data.txt
Team: Team Killaz<br />
Name: Bob<br />
Name: Frank<br />
--BREAK--
Team: People Hunters<br />
Name: Andy<br />
Name: Greg<br />
--BREAK--
Team: Water Boxers<br />
Name: Joann<br />
Name: Hector<br />
--BREAK--
Team: Dunkin Guns<br />
Name: Liz<br />
Name: Jessica<br />
--BREAK--
Team: Rain Walkers<br />
Name: John<br />
Name: Sue<br />
--BREAK--
Team: Rocker Gunners<br />
Name: Fred<br />
Name: Mike<br />