I'm trying to make a PHP program to make a "randomized poem" out of a set of inputed words (from a form). I have the PHP-backend to the point where it'll take the variables, randomly chooose a title, and echo the variables in the order they were put in.
What I want to do is randomize the order. I can't think of a way to do this so that a variable doesn't get chosen twice - in other words, I want to randomize the $w0 - $w14 variable's display order, with no one getting used twice. Below is what I have so far...
Any suggestions?
TIA
<?PHP
$r = rand(0,14);
$wnum = "w".$r;
$title = $$wnum;
echo "<font size='4'><u>";
echo $title;
echo "</font></u>";
echo "<br> <br>";
//get the words (15 of them)
for ($i = 0; $i < 15; $i++) {
$current = "w".$i;
if($current == "") {
break;
}
echo $$current;
//space
echo " ";
}
?>