You can dynamically create an array element without having to specify the index. e.g. you can do this:
$answer[] = 'a';
$answer[] = 'b';
and that will have the same result as
$answer = arra('a', 'b');
So in your loop, which checks each answer, if the answer is wrong, you just do
$answer[] = $correctValue;
Diego