How to select random files...

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
Anonymous2
Forum Newbie
Posts: 1
Joined: Sat Jan 31, 2004 11:14 am

How to select random files...

Post by Anonymous2 »

I need to know how to select a random file.

1.php
This file is the file that includes a random file when opened.
Either rand1.php rand2.php or rand3.php

How would I do this?

Something like using an include except it's randomised.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Code: Select all

//without the usual validation/checking you'de want to do
$rand = rand(1, 3);
$incfile = 'rand'.$rand.'.php';
require_once $incfile;
Post Reply