What is the quickest way to randomize a data set?
<p>For a multiple choice quiz application i would like to show the dummy answers with the correct answer. But with the correct answer being in a different position at each different question.</p>

<p>This is what i've tried but it doesn't seem to be working:</p>

<pre><code>if ($question-&gt;type == 1)
            {   

                echo "&lt;div id='dummy_answers'&gt;";
                //Show Dummy
                echo '&lt;h3&gt;Dummy Answers&lt;/h3&gt;';
                //Get Dummy Answers
                $query = $this-&gt;test_model-&gt;getDummyAnswers($question-&gt;id);
                $dummy_num = 1;
                foreach ($query-&gt;result() as $row)
                {
                    $rand_number = rand(1, 3);
                    if ($dummy_num == $rand_number)
                    {
                        $dummy_num = $rand_number + 2;
                        echo '&lt;h4&gt;Answer '.$dummy_num.'&lt;/h4&gt;';
                        echo '&lt;p&gt;';
                        echo $row-&gt;option;
                        echo '&lt;/p&gt;';
                        //Now echo the real answer
                        echo '&lt;h4&gt;Answer '.$rand_number.'&lt;/h4&gt;';
                        echo '&lt;p&gt;';
                        echo $row-&gt;option;
                        echo '&lt;/p&gt;'; //Get id's for each.echo $row-&gt;id;         
                    }
                    else
                    {
                        echo '&lt;h4&gt;Answer '.$dummy_num.'&lt;/h4&gt;';
                        echo '&lt;p&gt;';
                        echo $row-&gt;option;
                        echo '&lt;/p&gt;';
                        $dummy_num++;
                    }
                }
                echo '&lt;/div&gt;';
                echo '  &lt;hr/&gt;';
            }
        ?&gt;
</code></pre>
