Re: how to select a file on a random basis?

From: Date: Mon, 20 May 2002 09:47:31 +0000
Subject: Re: how to select a file on a random basis?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98442@lists.php.net to get a copy of this message
Ok well that array idea could work.. but what's the filename format of these files?? if they're all contigous or in some kind of pattern there maybe a faster and easier way such as if you have them for example named: file1.ext, file2.ext or some pattern or other.. then you can just use random number func's to do some work with you and all should be good.. ::::::::::::::::::::::::::::::::::::::::::: : Julien Bonastre [The-Spectrum.org CEO] : A.K.A. The_RadiX : the_radix@hotkey.net.au : ABN: 64 235 749 494 : QUT Student #: 04475739 ::::::::::::::::::::::::::::::::::::::::::: ----- Original Message ----- From: "Craig Vincent" <2bunnyhop@rogers.com> To: "Andy" <news.letters@gmx.de>; <php-general@lists.php.net> Sent: Monday, May 20, 2002 6:18 PM Subject: RE: [PHP] how to select a file on a random basis? > > I would like to pick a file out of a directory by random. There are 400 > > files and I just want to pick on of those by random. > > > > Is there a way with rand() and file ? > > Well there's a couple ways you could do this...it's too early in the morning > to post code but with some quick searches in the manual you should find all > you need. > > The most dynamic way to do this is to grab all the filenames in the > directory you want, then randomize the array using shuffle....then use the > first cell value in the array. > > If you don't understand what I'm suggesting just lmk =) I'll try explaining > in better detail when I'm more awake hehe. > > Sincerely, > > Craig Vincent > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#98442) next »