php script for random include?

MyKidsFan

New member
$randomNumber = 1; % however you get the random number

$filename = "/files/".$randomNumber."file.php";
include("$filename");

____
Update: Sure except that if you want it between 1 and 3 you would do
rand(1,3) not rand(5,15)
 
Hi,
I dont know much about php programming, but I want to write a line of code that will include a random file in a folder.

for example there are the following files:
/files/1file.php
/files/2file.php
/files/3file.php

now when the script loads i would like it to choose a random php file to display. For example the code might be something like

include '(random number 1 through 3)files.php';

please let me know how to do this.
thanks
Any more information on how to get the random number, thanks for what you posted so far
Would this work?

$randomNumber = rand(5, 15);

$filename = "/files/".$randomNumber."file.php";

include("$filename");
I GOT IT WORKING THANK YOU I LOVE YOU
 
Back
Top