Shuffling arrays
Posted: Thu Jul 23, 2009 8:25 am
Hi,
I'm writing an online testing system. I created an array with the answers:
;[/color]
To mix the answers I use shuffle($array) like this:
[/color]
The correct answer was originally $answer1. Is there a way to find out which option in the shuffled array is $answer1? Or is there a way to shuffle and keep te original array keys?
Thank you for your help.
I'm writing an online testing system. I created an array with the answers:
Code: Select all
//$i is the question number
$answer[$i.'answer1']=$answer1;
$answer[$i.'answer2']=$answer2;
$answer[$i.'answer3']=$answer3;
$answer[$i.'answer4']=$answer4To mix the answers I use shuffle($array) like this:
Code: Select all
$answer=shuffle($answer);The correct answer was originally $answer1. Is there a way to find out which option in the shuffled array is $answer1? Or is there a way to shuffle and keep te original array keys?
Thank you for your help.