Could it be a problem with the web server I am using or anything? The version of PHP it is running or anything. it seems weird I am just having this one problem
No, it is not a web server problem. The problem has to be that you are doing something outside of the code you posted previously. As I stated, I took the three blocks of code you posted in the initial message and ran it successfully. The only thing I had to do was set a value for $num to specify which question/answers I wanted displayed. To be honest, the code you are using is pretty crappy which has made me reluctant to try and fix your problem.
However, the only thing I can think of which would cause your problem would be if you run this line with one value for $num
shuffle_assoc($answers[$num]); And then run this with a different value for $num
foreach ($answers[$num] as $answer) {
$answer2 = str_replace($pattern,$replace,$answer);
echo "<li><input type=\"radio\" id=\"$answer2\" value=\"$answer2\" name=\"answers\" />\n";
echo "<label for=\"$answer2\">$answer</label></li>\n";
}
Since you never showed how you are setting $num, I can't really do more than guess.