RE: [PHP] how to select a file on a random basis?

From: Date: Mon, 20 May 2002 08:18:07 +0000
Subject: RE: [PHP] how to select a file on a random basis?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98435@lists.php.net to get a copy of this message
> 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

« previous php.general (#98435) next »