RE: [PHP] randomly picking a variable from an array

From: Date: Fri, 07 Sep 2001 20:24:45 +0000
Subject: RE: [PHP] randomly picking a variable from an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-66470@lists.php.net to get a copy of this message
On Fri, 7 Sep 2001, King, Justin wrote: > The easiest way I can think of would be to get a random number based on > the size of an array. If you're querying your database and filling an > array with all images, just use the database's random routine instead. > (I.E. "SELECT quote,author from randomQuote ORDER by RAND() LIMIT 1" in > mysql) > > If this isn't the case, something like this should work.. > > srand(time()); > $random=rand(0,sizeof($myVar)-1); > > Hope I could be of some help... > array_rand() will also do this for you... -Sterling > --Justin King, School District of Superior Web Coordinator > (www.superior.k12.wi.us) > > > -----Original Message----- > From: Joseph Bannon [mailto:JBannon@advparadigm.com] > Sent: Friday, September 07, 2001 2:08 PM > To: PHP (E-mail) > Subject: [PHP] randomly picking a variable from an array > > How do you randomly picking a variable from an array with PHP? > > Thanks, > > Joseph > > > > > PS. Thanks to those who helped me with GD. If you go to my site, you'll > see > the new counter I created at the top of the page. > > http://www.collegesucks.com > > > > > > > > > > > > > > > > > >

« previous php.general (#66470) next »