Re: shuffling an array (array generated from records in a database)
| From: | Greg Donald | Date: | Tue, 21 Sep 2004 21:57:24 +0000 |
| Subject: | Re: shuffling an array (array generated from records in a database) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-197496@lists.php.net to get a copy of this message | ||
On Tue, 21 Sep 2004 16:18:06 -0500, Ongkiko, Richard M
<ongkiko@uthscsa.edu> wrote:
> I am trying to implement some sort of a shuffle. What I am trying to do is a random shuffling
> of an array whose contents were records from a database. I am basically trying to
> shuffle/randomize, questions, so that different users will have different versions of questions in
> an exam, whose questions were extracted from a pool in a database, and shuffled. Can anybody out
> there help me out? Coding needed in PHP... thanks.
I'd do it in the SQL:
select * from table order by rand();
Otherwise PHP's shuffle() function may help you.
--
Greg Donald
http://gdconsultants.com/
http://destiney.com/