Random file chooser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mscorelle
Forum Newbie
Posts: 2
Joined: Sun Mar 13, 2005 10:02 am

Random file chooser

Post by mscorelle »

I'm looking for a way to randomly choose php files. I have php files set up like text ads, but I only want to display one at a time randomly. I haven't been able find a code that will do it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

  1. Figure out how to get a list of files. Difficulty: easy.
  2. Store the list of files in an array. Difficulty: easy.
  3. Use one of the random integer functions to choose one of those files: Difficulty: easy.
We've talked about #1 many times (search for opendir). The other two can be found in the php.net documentation quite easily.
mscorelle
Forum Newbie
Posts: 2
Joined: Sun Mar 13, 2005 10:02 am

Post by mscorelle »

Thank you
Post Reply