Re: shuffling an array (array generated from records in a database)

From: Date: Tue, 21 Sep 2004 21:52:38 +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-197494@lists.php.net to get a copy of this message
Ongkiko, Richard M 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. - Richard -
array_shuffle(), or you can randomize the order at database level, which is faster - for mysql use ORDER BY RAND()

« previous php.general (#197494) next »